# Elasticsearch span\_near query in greek text

**URL:** <https://discuss.elastic.co/t/elasticsearch-span-near-query-in-greek-text/381608>\
**Category:** Elasticsearch\
**Created:** [September 4, 2025, 2:27pm UTC](https://discuss.elastic.co/t/elasticsearch-span-near-query-in-greek-text/381608 "2025-09-04T14:27:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![epistola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/epistola/32/144908_2.png) [@epistola](https://discuss.elastic.co/u/epistola)\
**Post date:** [September 4, 2025, 2:27pm UTC](https://discuss.elastic.co/t/elasticsearch-span-near-query-in-greek-text/381608/1 "2025-09-04T14:27:40Z")

</div>

Hello everyone,

I have a problem with the following query:

```auto
 {
  "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.

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [September 5, 2025, 4:23am UTC](https://discuss.elastic.co/t/elasticsearch-span-near-query-in-greek-text/381608/2 "2025-09-05T04:23:55Z")

</div>

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)`

> **[Match phrase query | Reference](https://www.elastic.co/docs/reference/query-languages/query-dsl/query-dsl-match-query-phrase)**
>
> The match\_phrase query analyzes the text and creates a phrase query out of the analyzed text. For example: A phrase query matches terms up to a configurable...

> **[Elasticsearch Slop: Overview, Usage, Optimization & Examples](https://opster.com/guides/elasticsearch/search-apis/understanding-elasticsearch-slop-and-its-usage/)**
>
> In this article, we will explore the concept of slop in Elasticsearch, its usage, and how to optimize its value for better search results.

Thanks!!

---

<div class="post-metadata">

**Author:** ![epistola](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/epistola/32/144908_2.png) [@epistola](https://discuss.elastic.co/u/epistola)\
**Post date:** [September 5, 2025, 5:06am UTC](https://discuss.elastic.co/t/elasticsearch-span-near-query-in-greek-text/381608/3 "2025-09-05T05:06:13Z")

</div>

Hello @Tortoise

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