SpanNearQuery

Hi,everyone.

I want to use SpanNearQuery in my search request, i have set 'with_positions_offsets' to the 'term_vector' option of a text field property in mapping when i created a index .And then i indexed some docs to my
elasticsearch before i use SpanNearQuery to search my data.But it seems that the 'Slop' option of SpanNearQuery does not work ,the search result contains all matches data,no matter how far the distance between those words is.
Did I miss something?Or something wrong with my search way?

Could anybody please help me? I am so lucky if anybody can give me some ideas about this.I use the Nest client,the version of it is 2.0,And the version of elasticsearch is 2.2.0
Thank you !

Are you using a type = string field?

That should default to index = analyzed and index_options = positions which should make the span queries work.

Term vectors have nothing to do with searches finding matching documents; they are optionally used for highlighting.

Mike McCandless

Thanks for your reply!

I used a type=string field,and specified “search_analyzer”、“analyzer”、similarity”、“store”、“type” options for the Full-Text search field.

It is seems that the SpanNearQuery QueryContainer can not work together with FunctionScoreQuery.

Actually,I specified SpanNearQuery QueryContainer to the "Query" option of FunctionScoreQuery before i have some ideas on how to use SpanNearQuery.Then I found there was nothing related to SpanNearQuery in the JSON request to ES.So I got my Full-Text QueryContainer by SpanNearQuery only,and the two option "slop" and "inorder" worked.I am so amazing,but i still can not understand that how the "slop" option control the "span_term" clauses of SpanNearQuery.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.