Suppose I would like to search index with 2 term query.
I can do it with PhraseQuery(term1, term2, slop = 2) or with SpanNearQuery(term1, term2, slop=2, ordered=false)
.
What is the difference in lucene scoring for these configurations?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
To the best of my understanding, a phrase query with slop will tokenize the phrase, then apply the slop distance between each token, whereas in a span query a phrase will be retained as a unit.
So if you have a phrase query for "cat dog bird"
with slop 3
, it'd match cat horse lizard dog bird
.
But a span query for "cat dog" bird
with slop 3
would not match cat horse lizard dog bird
because cat
and dog
are not adjacent. It would, however, match: cat dog horse lizard bird
.