Highlighting on `match_phrase` with `index_phrases` enabled does not seem to work

I'm experimenting with the index_phrases functionality introduced in 6.4.0. When I use a match_phrase query and try to highlight the result, no highlights are returned. If I use match, I get highlights. Example:

DELETE test
PUT test
{
  "mappings": {
    "_doc": {
      "properties": {
        "voter": {
          "type": "text",
          "index_phrases": true
        }
      }
    }
  }
}

PUT test/_doc/1?refresh
{
  "voter": "John Paul Jones"
}

POST test/_search
{
  "query": {
    "match_phrase": {
      "voter": "Paul Jones"
    }
  },
  "highlight": {
    "fields": {
      "voter": {}
    }
  }
}

POST test/_search
{
  "query": {
    "match": {
      "voter": "Paul Jones"
    }
  },
  "highlight": {
    "fields": {
      "voter": {}
    }
  }
}

If I define the mapping without index_phrases, highlighting works as expected for match_phrase.

Is this a bug or an expected side-effect of index_phrases?

1 Like

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