# Annotated text highlighting not working for wildcard fields

**URL:** <https://discuss.elastic.co/t/annotated-text-highlighting-not-working-for-wildcard-fields/201803>\
**Category:** Elasticsearch\
**Created:** [October 1, 2019, 1:10pm UTC](https://discuss.elastic.co/t/annotated-text-highlighting-not-working-for-wildcard-fields/201803 "2019-10-01T13:10:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![robmartin11](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robmartin11/32/99177_2.png) [@robmartin11](https://discuss.elastic.co/u/robmartin11)\
**Post date:** [October 1, 2019, 1:10pm UTC](https://discuss.elastic.co/t/annotated-text-highlighting-not-working-for-wildcard-fields/201803/1 "2019-10-01T13:10:10Z")

</div>

Im indexing some text using the annotated text plugin eg

```auto
DELETE test1
PUT test
{
  "settings": {
    "number_of_shards": 1
  },
  "mappings": {
      "properties":{
        "text":{
          "type":"annotated_text"
        }
      }
  }
}
POST test/_doc/1
{
  "text":"he had a meeting with the [President of Mexico](Andrés+Obrador&Mexico) today"
}

```

When I perform a search with highlighting for a specific field all is good:

```auto
POST test/_search
{
    "query": {
        "term": {
            "text": "Andrés Obrador"
        }
    },
    "highlight": {
        "type": "annotated",
        "fields": {
            "text": {}
        }
    }
}

```

```auto
"hits": [
      {
        "_index": "test",
        "_type": "_doc",
        "_id": "1",
        "_score": 0.30873197,
        "_source": {
          "text": "he had a meeting with the [President of Mexico](Andrés+Obrador&Mexico) today"
        },
        "highlight": {
          "text": [
            "he had a meeting with the [President of Mexico](_hit_term=Andr%C3%A9s+Obrador&Andr%C3%A9s+Obrador&Mexico) today"
          ]
        }
      }
    ]

```

However if I perform the same search with a wildcard field the highlighting vanishes:

```auto
POST test/_search
{
    "query": {
        "term": {
            "text": "Andrés Obrador"
        }
    },
    "highlight": {
        "type": "annotated",
        "fields": {
            "*": {}
        }
    }
}

```

```auto
 "hits": [
      {
        "_index": "test",
        "_type": "_doc",
        "_id": "1",
        "_score": 0.30873197,
        "_source": {
          "text": "he had a meeting with the [President of Mexico](Andrés+Obrador&Mexico) today"
        }
      }
    ]

```

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [October 4, 2019, 9:41am UTC](https://discuss.elastic.co/t/annotated-text-highlighting-not-working-for-wildcard-fields/201803/2 "2019-10-04T09:41:46Z")

</div>

Hi Rob,  
Looking at the [docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-body.html#highlighting-settings) I can see that it says:

> Only text and keyword fields are highlighted when you use wildcards. If you use a custom mapper and want to highlight on a field anyway, you must explicitly specify that field name.

Being a non-core field type (for now) and not the `text` type this would explain why the `annotated_text` field type is overlooked. I'm afraid you'll have to explicitly list the field names to highlight in your request.

---

<div class="post-metadata">

**Author:** ![robmartin11](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robmartin11/32/99177_2.png) [@robmartin11](https://discuss.elastic.co/u/robmartin11)\
**Post date:** [October 4, 2019, 1:29pm UTC](https://discuss.elastic.co/t/annotated-text-highlighting-not-working-for-wildcard-fields/201803/3 "2019-10-04T13:29:43Z")

</div>

Thanks, Ill continue with specifying all available fields

---

<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:** [November 1, 2019, 1:30pm UTC](https://discuss.elastic.co/t/annotated-text-highlighting-not-working-for-wildcard-fields/201803/4 "2019-11-01T13:30:00Z")

</div>

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