# Incorrect highlight when using Intervals query (Elastic 7.1.1)

**URL:** <https://discuss.elastic.co/t/incorrect-highlight-when-using-intervals-query-elastic-7-1-1/186660>\
**Category:** Elasticsearch\
**Created:** [June 20, 2019, 10:56am UTC](https://discuss.elastic.co/t/incorrect-highlight-when-using-intervals-query-elastic-7-1-1/186660 "2019-06-20T10:56:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmitriev-kir](https://avatars.discourse-cdn.com/v4/letter/d/9fc348/32.png) [@dmitriev-kir](https://discuss.elastic.co/u/dmitriev-kir)\
**Post date:** [June 20, 2019, 10:56am UTC](https://discuss.elastic.co/t/incorrect-highlight-when-using-intervals-query-elastic-7-1-1/186660/1 "2019-06-20T10:56:13Z")

</div>

Hello!  
Please, clarify how intervals query works with highlighting in Elastic 7.1.1?

I researched features of interval query.  
Mapping:  
PUT test\_intervals\_index

```
{
  "mappings": {
    "dynamic": "strict",
    "properties": {
      "issue_date": { "format": "epoch_second", "type": "date" },
      "title": { "type": "text" },
      "content": { "type": "text" }
    }
  }
}

```

I executed query using intervals query and highlighting :

POST test\_intervals\_index/\_search

```
{
    "query": {
    "intervals": {
            "content": {
                "match": { "query": "new library", "max_gaps": 0, "ordered": true }
            }
        }
    },
    "highlight": {
        "fields": {
            "content": { "number_of_fragments": 0 }
        }
    }    
}

```

But hightlight object containts hightlighting phrases "_new_ _library_" and also separate words from search phrase, i.e. "_library_" (that do not have a word "new" near them).

For example, result of the query is:

```
{
  "took": 334,
  "timed_out": false,
  "_shards": {
    "total": 9,
    "successful": 9,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 0.5,
    "hits": [
      {
        "_index": "test_intervals_index",
        "_type": "_doc",
        "_id": "HtPUkmsB7JMoGnHxDfao",
        "_score": 0.5,
        "_source": {
          "issue_date": "1561507200",
          "title": "System.IO.Pipelines: High performance IO in .NET",
          "content": "System.IO.Pipelines is a new library that is designed to make it easier to do high performance IO in .NET. It’s a library targeting .NET Standard that works on all .NET implementations. Pipelines was born from the work the .NET Core team did to make Kestrel one of the fastest web servers in the industry. What started as an implementation detail inside of Kestrel progressed into a re-usable API that shipped in 2.1 as a first class BCL API (System.IO.Pipelines) available for all .NET developers."
        },
        "highlight": {
          "content": [
            "System.IO.Pipelines is a <em>new</em> <em>library</em> that is designed to make it easier to do high performance IO in .NET. It’s a <em>library</em> targeting .NET Standard that works on all .NET implementations. Pipelines was born from the work the .NET Core team did to make Kestrel one of the fastest web servers in the industry. What started as an implementation detail inside of Kestrel progressed into a re-usable API that shipped in 2.1 as a first class BCL API (System.IO.Pipelines) available for all .NET developers."
          ]
        }
      }
    ]
  }
}

```

Is this behavior correct? Or maybe I need to add some options for hightlight-query?

---

<div class="post-metadata">

**Author:** ![AlanWoodward](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alanwoodward/32/41962_2.png) [@AlanWoodward](https://discuss.elastic.co/u/AlanWoodward)\
**Post date:** [June 28, 2019, 9:38am UTC](https://discuss.elastic.co/t/incorrect-highlight-when-using-intervals-query-elastic-7-1-1/186660/2 "2019-06-28T09:38:54Z")

</div>

Unfortunately our highlighters don't currently handle intervals correctly, they fall back to just extracting individual terms and highlighting those. We're working on an improved highlighter that will use the underlying lucene Matches API, but it's a way off yet.

---

<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:** [July 26, 2019, 9:38am UTC](https://discuss.elastic.co/t/incorrect-highlight-when-using-intervals-query-elastic-7-1-1/186660/3 "2019-07-26T09:38:55Z")

</div>

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