# How highlighting work with intervals query?

**URL:** <https://discuss.elastic.co/t/how-highlighting-work-with-intervals-query/212735>\
**Category:** Elasticsearch\
**Created:** [December 21, 2019, 1:05pm UTC](https://discuss.elastic.co/t/how-highlighting-work-with-intervals-query/212735 "2019-12-21T13:05:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zeusfsx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zeusfsx/32/59433_2.png) [@zeusfsx](https://discuss.elastic.co/u/zeusfsx)\
**Post date:** [December 21, 2019, 1:05pm UTC](https://discuss.elastic.co/t/how-highlighting-work-with-intervals-query/212735/1 "2019-12-21T13:05:21Z")

</div>

I have a document:

```auto
{
    'title': 'something',
   'text': 'Nova poshta one two three four five six seven eight nine ten words poshta '
}

```

```auto
{
    "query": {
        "intervals": {
            "text" : {
                "all_of": {
                    "max_gaps": 0,
                    "ordered": True,
                    "intervals": [
                            {
                                "match": {
                                    "query": "Nova Poshta",
                                    "use_field": "text.exact",
                                    "analyzer": "default",
                                    "max_gaps": 0
                                }
                            }
                    ] 
                }
                
            }
        }
    },
    "highlight": {
         "pre_tags": ["<em>"],
         "post_tags": ["</em>"],
         "fields": [
             {
                 "text.*": {
                     "type": "plain",
                     "number_of_fragments": 0,
                     "fragmenter": "simple"
                 }
             },
         ]
     },
     "size": 10
}

```

Elastic give me result:

```auto
'highlight': {'text.exact': ['<em>Nova</em> <em>poshta</em> one two three four five six seven eight nine ten words <em>poshta</em> ']}}

```

Why elastic highlight last word, I set `max_gaps=0` for the match? Can someone explain it for me?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 18, 2020, 1:05pm UTC](https://discuss.elastic.co/t/how-highlighting-work-with-intervals-query/212735/2 "2020-01-18T13:05:25Z")

</div>

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