为查询添加模糊性
有没有一种简单的方法可以为用户在 Lucene 中输入的搜索查询添加模糊级别?
如果可能的话,我想避免解析他们输入的文本。
目前,如果他们输入绿色框
,我使用带有增强功能的多字段查询解析器,它可以轻松生成以下内容,例如:
+(title:green^10 title:boxes^10) +(category:green^3 category:boxes^3)
然后我想做的是将其转换为:
+(title:green^10~0.7 title:boxes^10~0.7) +(category:green^3~0.7 category:boxes^3~0.7)
它看起来像我需要解析查询并向每个术语添加模糊性,但我想知道是否有一种简单的方法来添加模糊性?
Is there a simple way to add a fuzziness level to a user entered search query in Lucene?
I'd like to avoid having to parse their entered text if possible.
At present if they enter green boxes
I use a multifield query parser with boosts which easily generates the following for example:
+(title:green^10 title:boxes^10) +(category:green^3 category:boxes^3)
What I'd like to then do is convert this to:
+(title:green^10~0.7 title:boxes^10~0.7) +(category:green^3~0.7 category:boxes^3~0.7)
It looks like I'd need to parse the query and add the fuzziness to each term but I was wondering if maybe there's a simple way to add the fuzziness?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另一种方法是子类化并覆盖 MultiFieldQueryParser .getFieldQuery,让它调用getFuzzyQuery。
Another way is to subclass and override MultiFieldQueryParser.getFieldQuery, having it call getFuzzyQuery.