# Highlighting issue when combine multiword phrase search with Intervals

**URL:** <https://discuss.elastic.co/t/highlighting-issue-when-combine-multiword-phrase-search-with-intervals/282085>\
**Category:** Elasticsearch\
**Created:** [August 20, 2021, 1:53pm UTC](https://discuss.elastic.co/t/highlighting-issue-when-combine-multiword-phrase-search-with-intervals/282085 "2021-08-20T13:53:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yury-Stanevitch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yury-stanevitch/32/93508_2.png) [@Yury-Stanevitch](https://discuss.elastic.co/u/Yury-Stanevitch)\
**Post date:** [August 20, 2021, 1:53pm UTC](https://discuss.elastic.co/t/highlighting-issue-when-combine-multiword-phrase-search-with-intervals/282085/1 "2021-08-20T13:53:42Z")

</div>

Hello. I have query which works good from highlighting standpoint:

```auto
POST index/_search
{
  "highlight": {
    "fields": {
      "attrText*": {
        "number_of_fragments": 0,
        "type": "unified"
      }
    },
    "fragmenter": "simple",
    "post_tags": [
      "[/H]"
    ],
    "pre_tags": [
      "[H]"
    ],
    "require_field_match": true
  },
  "query": {
    "bool": {
      "must": [
        {
          "bool": {
            "should": [
              {
                "multi_match": {
                  "fields": [
                    "attrText",
                    "attrText.exact"
                  ],
                  "query": "Orange",
                  "type": "phrase"
                }
              },
              {
                "bool": {
                  "should": [
                    {
                      "multi_match": {
                        "fields": [
                          "attrText.exact"
                        ],
                        "query": "A-T-T"
                      }
                    },
                    {
                      "intervals": {
                        "attrText": {
                          "all_of": {
                            "intervals": [
                              {
                                "all_of": {
                                  "intervals": [
                                    {
                                      "match": {
                                        "max_gaps": 0,
                                        "ordered": true,
                                        "query": "A",
                                        "use_field": "attrText"
                                      }
                                    },
                                    {
                                      "match": {
                                        "max_gaps": 0,
                                        "ordered": true,
                                        "query": "T",
                                        "use_field": "attrText"
                                      }
                                    }
                                  ],
                                  "max_gaps": 0,
                                  "ordered": true
                                }
                              },
                              {
                                "all_of": {
                                  "intervals": [
                                    {
                                      "match": {
                                        "max_gaps": 0,
                                        "ordered": true,
                                        "query": "T",
                                        "use_field": "attrText"
                                      }
                                    },
                                    {
                                      "match": {
                                        "max_gaps": 0,
                                        "ordered": true,
                                        "query": "T",
                                        "use_field": "attrText"
                                      }
                                    }
                                  ],
                                  "max_gaps": 0,
                                  "ordered": true
                                }
                              }
                            ],
                            "max_gaps": 0
                          }
                        }
                      }
                    },
                    {
                      "intervals": {
                        "attrText": {
                          "all_of": {
                            "intervals": [
                              {
                                "match": {
                                  "max_gaps": 0,
                                  "ordered": true,
                                  "query": "A",
                                  "use_field": "attrText"
                                }
                              },
                              {
                                "match": {
                                  "max_gaps": 0,
                                  "ordered": true,
                                  "query": "TT",
                                  "use_field": "attrText"
                                }
                              }
                            ],
                            "max_gaps": 0,
                            "ordered": true
                          }
                        }
                      }
                    },
                    {
                      "intervals": {
                        "attrText": {
                          "all_of": {
                            "intervals": [
                              {
                                "match": {
                                  "max_gaps": 0,
                                  "ordered": true,
                                  "query": "AT",
                                  "use_field": "attrText"
                                }
                              },
                              {
                                "match": {
                                  "max_gaps": 0,
                                  "ordered": true,
                                  "query": "T",
                                  "use_field": "attrText"
                                }
                              }
                            ],
                            "max_gaps": 0,
                            "ordered": true
                          }
                        }
                      }
                    },
                    {
                      "multi_match": {
                        "fields": [
                          "attrText"
                        ],
                        "query": "ATT"
                      }
                    }
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  }
}

```

But if to change string "Orange" above with a multi word phrase like "Apple Orange" then highlighting information stopping to return for most of the results. The difference in results on UI looks like this:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/b/eb23efeba614815199deec8ac199173a676de8c4.png)  
We have two fields in the index. One for regular search and the other for exact search. For regular search field we have char\_filter which replaces underscores with spaces and removes many of special characters.  
We use Elasticsearch of version 7.7 on premises.  
This looks like an error.

---

<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:** [September 17, 2021, 1:54pm UTC](https://discuss.elastic.co/t/highlighting-issue-when-combine-multiword-phrase-search-with-intervals/282085/2 "2021-09-17T13:54:41Z")

</div>

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