infinilabs / analysis-ik

🚌 The IK Analysis plugin integrates Lucene IK analyzer into Elasticsearch and OpenSearch, support customized dictionary.
Apache License 2.0
16.44k stars 3.27k forks source link

match_phrase结合ik_max_word分词模式,无法查询到结果 #955

Open jikefenger opened 2 years ago

jikefenger commented 2 years ago

1、创建索引时,name使用ik_max_word分词器 2、插入数据"珠江桥牌御品蚝油" 3、使用关键字 ”珠江桥“ 查询时,使用ik_smart分词器,并且设置了足够大的slop,查询不到无结果 GET product_index/_search { "query": { "dis_max": { "queries": [ { "match_phrase": { "name": { "query": "珠江桥", "analyzer": "ik_smart", "slop": 20 } } }] } } }

”珠江桥牌御品蚝油“使用ik_max_word的分词结果是: { "tokens" : [ { "token" : "珠江", "start_offset" : 0, "end_offset" : 2, "type" : "CN_WORD", "position" : 0 }, { "token" : "珠", "start_offset" : 0, "end_offset" : 1, "type" : "CN_WORD", "position" : 1 }, { "token" : "江", "start_offset" : 1, "end_offset" : 2, "type" : "CN_WORD", "position" : 2 }, { "token" : "桥牌", "start_offset" : 2, "end_offset" : 4, "type" : "CN_WORD", "position" : 3 }, { "token" : "桥", "start_offset" : 2, "end_offset" : 3, "type" : "CN_WORD", "position" : 4 }, { "token" : "牌", "start_offset" : 3, "end_offset" : 4, "type" : "CN_WORD", "position" : 5 }, { "token" : "御", "start_offset" : 4, "end_offset" : 5, "type" : "CN_WORD", "position" : 6 }, { "token" : "品", "start_offset" : 5, "end_offset" : 6, "type" : "CN_WORD", "position" : 7 }, { "token" : "蚝油", "start_offset" : 6, "end_offset" : 8, "type" : "CN_WORD", "position" : 8 }, { "token" : "蚝", "start_offset" : 6, "end_offset" : 7, "type" : "CN_WORD", "position" : 9 }, { "token" : "油", "start_offset" : 7, "end_offset" : 8, "type" : "CN_WORD", "position" : 10 } ] }

”珠江桥“使用ik_smart的分词结果是: { "tokens" : [ { "token" : "珠江", "start_offset" : 0, "end_offset" : 2, "type" : "CN_WORD", "position" : 0 }, { "token" : "桥", "start_offset" : 2, "end_offset" : 3, "type" : "CN_WORD", "position" : 1 } ] }

yongjie1992 commented 2 years ago

我也遇到了这种情况,查询的时候的吧"analyzer": "ik_smart"换成"analyzer": "ik_max_word"就可以查到