What is the difference between SpanQuery and Phras

2019-04-17 14:33发布

问题:

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.



标签: solr lucene