开发者

PhraseQuery: are the terms strictly searched in their order?

开发者 https://www.devze.com 2023-02-14 09:19 出处:网络
Are terms searched with a PhraseQuery in Lucene, s开发者_如何转开发trictly matched in their order in the sentence ?

Are terms searched with a PhraseQuery in Lucene, s开发者_如何转开发trictly matched in their order in the sentence ?

For example, if I have "A B C" and the doc contains "A C B", is PhraseQuery returning a hit ?

thanks


Yes, order matters. So in your example, the query "A B C" would NOT match a doc containing "A C B".


Not if you use slop in your PhraseQuery.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号