Mazz
Mazz

Reputation: 71

What's the difference between SpanWithInQuery and SpanContainingQuery in Elasticsearch?

I am confused about the difference between these two queries. From the official document, my understanding is that both of these queries make a intersection of result Big and result Little. But if in this way, the final returned matches of these two are same.

Hope someone can give us an explanation of this, examples better.

Thanks

Upvotes: 0

Views: 436

Answers (1)

Val
Val

Reputation: 217354

From the official documentation, SpanContainingQuery will return...

...matching spans from big that contain matches from little

whereas SpanWithinQuery will return...

...matching spans from little that are enclosed within big

In clear, the former will keep matches that contain another Spans, while the latter will keep matches that are contained within another Spans.

You can find a few usage examples of both in the official Lucene test cases.

Upvotes: 2

Related Questions