New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
类似#195的match_phrase问题 #204
Comments
@smilesfc 麻烦贴完整可复现的restful脚本,我这边测试没有你说的问题,和position没有关系的 PUT index/type3/1 POST index/type3/_search
|
就你贴的这个脚本就可以,但是"募集资金"是添加在自定义词典myDict里面的。如果不加这个词的话没有问题,加了之后才出现的。 |
@smilesfc 我加到词典里面也没有出现这个问题,完整的复现流程贴一下吧,和我上面的格式一样,用sense |
@medcl
附上 "北京宝软科技有限公司" 分词器结果,我肉眼看看觉得也没啥问题:
|
词典修改之后,需要重建索引的 |
|
@wuyadong 麻烦给我一下复现脚本吧 |
@medcl 如下,
|
@wuyadong |
@wuyadong 奇怪,我什么我这边用你的脚本就是无法复现,都是能查出来的,也是用的2.3 |
@medcl 难道是其它配置导致的?我读了下配置: mapping
ik字典扩展配置,只保留了停止词扩展和自己的字典;字典里有 北京宝软科技有限公司、宝软科技有限公司、有限公司等等,还比较多。
ES配置,仅配置IK分词器,其它就是本地IP之类配置,不会有影响:
|
@medcl
北京宝软科技有限公司 结果:
|
@smilesfc @medcl
搜索
结果
|
@medcl 我刚又脚步测试了下,使用 ik_max_word,又正常了,我重建下index看看是不是生产数据库也会正常? 重建好痛苦。 |
我还是觉得这里面有雷,我仔细研究下分词的源码。 |
phrase 会使用到 position,phrase 适合分出来的词没有位置重叠的场景,如果有重叠,slop 计算的时候可能会有问题 |
相同的问题 @medcl @smilesfc 能否帮看下是为什么
|
搜索 金砖国家 出不来结果。slop 设置为1 可以。但是 金砖国家 明明是相邻的啊。@medcl |
es 和 ik 都是 5.4.0 |
medcl大神,我觉的ik分词的position可能有问题
先描述下问题:原文中为“前次募集资金”,索引用的ik_max_word,搜索时match_phrase搜“前次募集资金”没问题,match_phrase搜“前次募集”啥也搜不到。
ik_max_word的analyzer测试:
_analyze?analyzer=ik_max_word&text=前次募集资金
返回:
{"tokens":[{"token":"前次","start_offset":0,"end_offset":2,"type":"CN_WORD","position":0},{"token":"募集","start_offset":2,"end_offset":4,"type":"CN_WORD","position":1},{"token":"募","start_offset":2,"end_offset":3,"type":"CN_WORD","position":2},{"token":"集","start_offset":3,"end_offset":4,"type":"CN_CHAR","position":3},{"token":"基金","start_offset":4,"end_offset":6,"type":"CN_WORD","position":4}]}
相关mapping:
[ElasticProperty(IncludeInAll = false, IndexAnalyzer = "ik_max_word", SearchAnalyzer = "ik_max_word")] public string Title { get; set; }
第一次用“前次募集资金”搜索:
返回有结果:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":21,"max_score":3.6136353,"hits":[{"_index":"disclosure.main.alpha","_type":"esdisclosurecomp","_id":"73419","_score":3.6136353,"highlight":{"title":["国金证券:<em>前次募集资金</em>使用情况报告"]}}]}}
然后第二次去掉“资金”:
此时返回无匹配:
{"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
我就奇了怪了,于是加了term vector,翻国金证券这篇,找到:
我觉得问题就在这里,在ik_max_word下,募集资金本身是一个完整的词,同时又可以被分为募集和资金,而募集的position离前次已经差1个词了,所以match_phrase不认为前次募集可以构成一个词组。您看看是不是这么回事,然后想问下有没有解决的方法,谢谢!
The text was updated successfully, but these errors were encountered: