-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
搜索关键字“珀”,在ik_smart模式下缺找不到含有“琥珀”二字的文档 #271
Comments
试试ik_max_word,要么就加使用一个更细的分词的字段 |
@medcl 谢谢回复,我试过了ik_max_word,但是还是将“琥珀”分成了一个词,并没有更细粒度的拆分。 |
这确实是个很矛盾的事情,一方面想尽可能合理的进行分词,一方面想搜索单字。 |
可以使用multifield,一个字段一个分词不可能都实现你的需求 |
好的我去学习一下,谢谢。 |
字典里加个“珀“? |
推荐创建索引的时候尽量分词分细一点。比如analyzer设置成ik_max_word. 然后搜索的时候用ik_smart. |
@davidcai19840412 that's what I'm doing now |
这个问题有个简单的方法,扩展词典中加入单字词典,索引分词采用ik_max_word模式会将单字索引,search_analyzer采用ik_smart,可以解决这个单字漏索引的问题 |
@xupengrun 请问单字词典可以在哪里找?有没有详细的教程?谢谢 |
复现很简单,在某个索引的某个字段中创建一个
type: string
,analyzer: ik_smart
的字段,假设名为description。然后填入这么一条数据:主要经营缅甸琥珀蜜蜡各类产品 翡翠各类成品及半成品 18k金镶嵌成品 低中高价位齐全 产品款式 大量库存
。通过ik_smart分词器查看其分词结果:(截取部分)
可以看出琥珀被分为一个词了。那么再进行以下查询,仅查找“珀”字:
结果缺找不到该字。我认为原因应该是,ik_smart将“琥珀”认为是一个词后,为这个词进行了索引。那么搜索“珀”字自然找不到这条数据。
通过测试,发现自带standard分词器是可以通过搜索“珀”字,搜索到含有“琥珀”的数据的。原因明显是因为standard分词器会拆分每个汉字。
不知道各位都怎么解决这个问题,谢谢。
The text was updated successfully, but these errors were encountered: