本文介绍了Lucene反向短语搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我要搜索关键字错误消息",lucene是否可以将匹配错误消息"和消息错误"的结果借给我. Currenlty我得到的结果仅与错误消息"匹配.我正在使用Standard Analyzer和Query Parser来搜索关键字.
If I want to search for Keyword "Error Message" , Can lucene be able to lend me results matching "Error Message" and "Message Error". Currenlty i am getting results matching "Error Message" Only. I am using Standard Analyser and Query Parser for searching a Keyword.
推荐答案
使用坡度> 0的PhraseQuery
.来自 javadoc :
Use a PhraseQuery
with slop > 0. From the javadoc:
更精确的比赛的得分高于更残酷的比赛,因此 搜索结果按准确性排序.
More exact matches are scored higher than sloppier matches, thus search results are sorted by exactness.
默认情况下,斜率为零,要求完全匹配.
The slop is zero by default, requiring exact matches.
这篇关于Lucene反向短语搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!