Elasticsearch span_near query in greek text

Hello everyone,

I have a problem with the following query:

 {
  "query": {
    "span_near": {
      "clauses": [
        {
          "span_near": {
            "clauses": [
              { "span_term": { "text1": "word1" } },
              { "span_term": { "text1": "word2" } },
            ],
            "slop": 0,
            "in_order": true
          }
        },
        { "span_term": { "text1": "word3" } }
      ],
      "slop": 3,
      "in_order": false
    }
  }
}

I want to search with [word1 word2] next to each other while [word3] is at slop distance from the other two.

The above query returns 1 document that matches the criteria. If i increase the outer slop, the document is returned but this is not the correct behaviour. The distance between the inner block of [word1 word2] is 3 words away from the word3. Why it matches the documents?

If i decrease the slop, does not match any document (correct behaviour).

The analyzer i use for the text field is the greek one.

Thanks in advance for any advice.

Hello @epistola

Welcome to the Community!!

As per the documentation for slop , so when we increase the outer slop from 3 to 4 , 5 ,6 …it still matches as when we say 6 it is upto 6 (so 1,2,3,4,5,6).
Hence it seems when you increase the outer slop value there is no difference because if the value is returned for slop value 3 it will return for any higher value greater than 3 & once you start reducing the slop it will not return the values.

matches terms up to a configurable slop (which defaults to 0)

Thanks!!

Hello @Tortoise

I had forgot that matches terms up to a given value. Thanks for your reply.