Highlight produce unexpected invalid results on multivalue fields copied from other fields

Steps to reproduce

  1. create mapping
post /test/_mapping 
{
    "properties": {
      
      "family": {
            "type": "text",
            "index": true,
            "term_vector": "with_positions_offsets",
            "store": false
      },
      "person":{
            "type": "keyword",
            "index": true,
            "store": true,
            "copy_to":["family"]
      },
      "sisters":{
            "type": "keyword",
            "index": true,
            "store": true,
            "copy_to":["family"]
      },
      "brothers":{
            "type": "keyword",
            "index": true,
            "store": true,
            "copy_to":["family"]
      }
    }
}
  1. post a document
POST  /test/_doc/1
{
  "person":"john doe jr",
  "sisters":["pam doe jr","ann doe older"],
  "brothers":["peter doe jr third"]
}

3 Perform search

POST /test/_search
{
  "query":{
    "match": {
      "family": "doe jr"
    }
  },
  "highlight": {
    "fields": {
          "family": { }
    }
  }
}

Unexpected invalid results of highlighter

"highlight": {
          "family": [
            "john <em>doe</em> <em>jr</em>",
            "pete<em>r d</em>o<em>e </em>jr th<em>ird</em>",
            "a<em>nn </em>d<em>oe</em> older"
          ]
        }

Forgot to mention server Version is 8.4.1

Please, Can anybody check and confirm this bug

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