analysis-ik icon indicating copy to clipboard operation
analysis-ik copied to clipboard

About IK + Phrase Suggester

Open cailurus opened this issue 6 years ago • 15 comments

Hi @medcl

最近在打算使用 Phrase Suggester 的时候碰到点困难,想咨询下是不是哪里出了问题。

比方说我的 Mapping 是这样设置的:

"title_zh": {"type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word"} "title_en": {"type": "text"}

title_zh和title_en分别是document中两个field,title_zh采用IK分词,title_en采用默认的分词。

随后我随便塞一个document进去,其中两个字段内容分别是: "title_zh": "苹果手机", "title_en":"apple iphone"

接下来我想使用 Phrase suggester 的功能:

curl -XPOST 'localhost:9200/anew/_search?pretty' -H 'Content-Type: application/json' -d' { "suggest": { "text": "applo iphene", "simple_phrase": { "phrase": { "field": "title_en", "size": 1, "gram_size": 3, "highlight": { "pre_tag": "<em>", "post_tag": "</em>" } } } } } '

返回结果是我想要的: { "took" : 2, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 0, "max_score" : 0.0, "hits" : [ ] }, "suggest" : { "simple_phrase" : [ { "text" : "applo iphene", "offset" : 0, "length" : 12, "options" : [ { "text" : "applo iphone", "highlighted" : "applo <em>iphone</em>", "score" : 0.24598429 } ] } ] } }

但是换做title_zh这个field却不行,是哪里配置不对呢? curl -XPOST 'localhost:9200/anew/_search?pretty' -H 'Content-Type: application/json' -d' { "suggest": { "text": "平果手机", "simple_phrase": { "phrase": { "field": "title_zh", "size": 1, "gram_size": 3, "highlight": { "pre_tag": "<em>", "post_tag": "</em>" } } } } } '

{ "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 0, "max_score" : 0.0, "hits" : [ ] }, "suggest" : { "simple_phrase" : [ { "text" : "平果手机", "offset" : 0, "length" : 4, "options" : [ ] } ] } }

cailurus avatar Oct 02 '17 11:10 cailurus

ik_max_word 不适合 phrase 查询,可以换成 smart 么

medcl avatar Oct 09 '17 06:10 medcl

@medcl 将mapping中title_zh这个field改成了: "title_zh": {"type": "text", "analyzer": "ik_smart"}

其他均不变,依然是空返回,还需要其他的设置吗?

cailurus avatar Oct 10 '17 03:10 cailurus

@ailurus1991 哥们,你解决了没?我也遇到同样的问题了,英文的参照官网没问题,但用中文就有问题

haochun avatar May 04 '18 09:05 haochun

@haochun 没有,放弃 Phrase Suggester 这个方案了。

cailurus avatar May 05 '18 15:05 cailurus

@ailurus1991 请问你怎么处理的呢

haochun avatar May 08 '18 08:05 haochun

ik_smart确实也遇到这个问题,请问是否已经解决了?谢谢

ghost avatar Aug 12 '19 05:08 ghost

#266

ghost avatar Aug 12 '19 05:08 ghost

加一,terms也是不行

meme-lau avatar Jan 08 '20 07:01 meme-lau

请问有解决方案了吗

baixiaoshi avatar Jan 04 '21 03:01 baixiaoshi

请问有解决办法没

curryQin avatar Feb 07 '21 09:02 curryQin

@uxnow @medcl @cailurus @baixiaoshi 你们有啥解决方案了么 推荐词中文纠错这个根们没任何返回结果

curryQin avatar Feb 09 '21 03:02 curryQin

没有

ghost avatar Feb 09 '21 03:02 ghost

@curryQin 需要在term suggest时加上min_word_length=2。默认值为4,而一般中文词的长度都小于4,设置为2比较合适。

lsz8888 avatar Feb 19 '21 01:02 lsz8888

@curryQin 需要在term suggest时加上min_word_length=2。默认值为4,而一般中文词的长度都小于4,设置为2比较合适。 二(四)两拨千斤!

flyinghawker avatar Feb 26 '21 14:02 flyinghawker

感谢两位大佬@lsz8888@flyinghawker

curryQin avatar Mar 01 '21 01:03 curryQin