Highlighting issue when combine multiword phrase search with Intervals

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

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:


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.

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