Lucene反向短语搜索 [英] Lucene Reverse Phrase Search

查看:103
本文介绍了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.来自

Use a PhraseQuery with slop > 0. From the javadoc:

设置查询中单词之间允许的其他单词数 短语.如果为零,则这是一个精确的短语搜索.对于更大的 值,它的工作方式类似于WITHIN或NEAR运算符.其实是 编辑距离,单位对应于 查询词组位置不正确.例如,切换两个的顺序 单词需要两个动作(第一个动作将单词放在一个单词的上面 另一个),因此要允许对短语进行重新排序,斜线必须位于 至少两个.

Sets the number of other words permitted between words in query phrase. If zero, then this is an exact phrase search. For larger values this works like a WITHIN or NEAR operator. The slop is in fact an edit-distance, where the units correspond to moves of terms in the query phrase out of position. For example, to switch the order of two words requires two moves (the first move places the words atop one another), so to permit re-orderings of phrases, the slop must be at least two.

更精确的比赛的得分高于更残酷的比赛,因此 搜索结果按准确性排序.

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反向短语搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆