# Elasticsearch - Highlight of wildcard

**URL:** <https://discuss.elastic.co/t/elasticsearch-highlight-of-wildcard/165939>\
**Category:** Elasticsearch\
**Created:** [January 28, 2019, 6:12am UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-wildcard/165939 "2019-01-28T06:12:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikesh/32/86579_2.png) [@Nikesh](https://discuss.elastic.co/u/Nikesh)\
**Post date:** [January 28, 2019, 6:12am UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-wildcard/165939/1 "2019-01-28T06:12:36Z")

</div>

Hi,

I have found a behaviour of highlight of wildcard little different.  
When I search using single "_" i.e., a wildcard character, It does not highlight any of the values.  
But if I do the same using two or more "_" i.e., wildcard character, It does highlight all the values.  
Although the results fetched are the same, why is there such a difference in highlight?  
example : 1. Multiple wildcards

```
{
    "from" : 0, "size" : 10,"_source": {"includes":["ID"]
}, "query": {
    "bool": {"should": [ {
    "bool": {"must": [ {
          "query_string": {
            "query":"**",
            "fields":["ID"]
}}]}}],"minimum_should_match":1}},"highlight": {
        "type" : "unified",
           "fragment_size" : 0,
           "order":"score",
			"number_of_fragments" :4,
        "fields": {
            "*": {
            }           	 
        }
    }
   }

```

Results :

```
    {
                    "_index": "index_name",
                    "_type": "_doc",
                    "_id": "AUTO",
                    "_score": 1,
                    "_source": {
                        "ID": "AUTO"
                    },
                    "highlight": {
                        "ID": [
                            "<em>AUTO</em>"
                        ]
                    }
                }

```

1. Singular Wildcard

{  
"from" : 0, "size" : 10,"\_source": {"includes":["ID"]  
}, "query": {  
"bool": {"should": [ {  
"bool": {"must": [ {  
"query\_string": {  
"query":"_",  
"fields":["ID"]  
}}]}}],"minimum\_should\_match":1}},"highlight": {  
"type" : "unified",  
"fragment\_size" : 0,  
"order":"score",  
"number\_of\_fragments" :4,  
"fields": {  
"_": {  
}   
}  
}  
}

Results :

```
{ "_index": "index_name",
                "_type": "_doc",
                "_id": "AUTO",
                "_score": 1,
                "_source": {
                    "ID": "AUTO"
                }
            }
```

---

<div class="post-metadata">

**Author:** ![Nikesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nikesh/32/86579_2.png) [@Nikesh](https://discuss.elastic.co/u/Nikesh)\
**Post date:** [January 29, 2019, 11:09am UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-wildcard/165939/2 "2019-01-29T11:09:55Z")

</div>

@elastic Could you please provide any inputs?

---

<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:** [February 26, 2019, 11:09am UTC](https://discuss.elastic.co/t/elasticsearch-highlight-of-wildcard/165939/3 "2019-02-26T11:09:58Z")

</div>

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