Highlight each span_term with a different tag

Is it possible to highlight each span_term with a different tag?

For example:

PUT /my_index/_doc/1
{
  "text": "my interesting book"
}

then:

GET /my_index/_search
{
  "query": {
    "span_near": {
      "clauses": [
        { "span_term": { "text": { "value": "my" } }},
        { "span_gap": { "text": 1 }},
        { "span_term": { "text": { "value": "book" }}}
      ],
      "slop": 0,
      "in_order": true
    }
  },
  "highlight": {
    "number_of_fragments": 0,
    "fields": {
      "text": {
        "highlight_query": {
          "span_near": {
            "clauses": [
              { "span_term": { "text": { "value": "my" }}},
              { "span_multi": { "match": { "wildcard": { "text": "*" }}}},
              { "span_term": { "text": { "value": "book" }}}
            ],
            "slop": 0,
            "in_order": true
          }
        }
      }
    }
  }
}

returns:

<em>my</em> <em>interesting</em> <em>book</em>

Desirable result:

<em>my</em> <strong>interesting</strong> <em>book</em>

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