# Highlight works not always!

**URL:** <https://discuss.elastic.co/t/highlight-works-not-always/19702>\
**Category:** Elasticsearch\
**Created:** [September 10, 2014, 7:45am UTC](https://discuss.elastic.co/t/highlight-works-not-always/19702 "2014-09-10T07:45:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramy](https://avatars.discourse-cdn.com/v4/letter/r/8491ac/32.png) [@Ramy](https://discuss.elastic.co/u/Ramy)\
**Post date:** [September 10, 2014, 7:45am UTC](https://discuss.elastic.co/t/highlight-works-not-always/19702/1 "2014-09-10T07:45:54Z")

</div>

Can someone tell me, why the highlighting works not always? what is my  
mistake?

This is my mapping:

curl -XPUT "[http://localhost:9200/my\_index](http://localhost:9200/my_index)" -d'  
{  
"settings": {  
"analysis": {  
"analyzer": {  
"autocomplete": {  
"type": "custom",  
"tokenizer": "ngram\_tokenizer",  
"filter": ["lowercase"]  
}  
},  
"tokenizer": {  
"ngram\_tokenizer": {  
"type": "ngram",  
"min\_gram": 1,  
"max\_gram": 20,  
"token\_chars": ["letter", "digit"]  
}  
}  
}  
},  
...  
}'

and here is my query:

curl -XGET "[http://localhost:9200/my\_index/my\_type/\_search](http://localhost:9200/my_index/my_type/_search)" -d'  
{  
"\_source": false,  
"size": 5,  
"query": {  
"multi\_match": {  
"query": "_tisch_",  
"fields": [  
"_\_de.autocomplete"  
],  
"operator": "and"  
}  
},  
"highlight": {  
"pre\_tags": [  
"**"  
],  
"post\_tags": [  
"**"  
],  
"fields": {  
"_\_de.autocomplete": {}  
}  
}  
}'

and this is my result:

{  
"took": 220,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 3649,  
"max\_score": 0.88375586,  
"hits": [  
{  
"\_index": "my\_index",  
"\_type": "my\_type",  
"\_id": "1",  
"\_score": 0.88375586,  
"highlight": {  
"group\_name\_3\_de.autocomplete": [  
"Konsol_tisch_e",  
"Garten-Ess **_tisch_** e"  
],  
"group\_name\_2\_de.autocomplete": [  
" **_Tisch_** e",  
"Gartentische"  
]  
}  
},  
{  
"\_index": "my\_index",  
"\_type": "my\_type",  
"\_id": "2",  
"\_score": 0.88375586,  
"highlight": {  
"group\_name\_3\_de.autocomplete": [  
"Schreib_tisch_e",  
"Ess **_tisch_** e"  
],  
"group\_name\_2\_de.autocomplete": [  
" **_Tisch_** e"  
]  
}  
},  
{  
"\_index": "my\_index",  
"\_type": "my\_type",  
"\_id": "3",  
"\_score": 0.88375586,  
"highlight": {  
"group\_name\_3\_de.autocomplete": [  
"Einzel_tisch_e"  
],  
"group\_name\_2\_de.autocomplete": [  
"Büro **_tisch_** e"  
]  
}  
},  
...  
]  
}  
}

As you can see. Elasticsearch was able to highlight some words. I marked  
them as _pink_ and the other are marked as _red_

Where is the failure?

Thank you

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/ce7b0413-f113-4819-bd24-0499488b7ecf%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/ce7b0413-f113-4819-bd24-0499488b7ecf%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:03am UTC](https://discuss.elastic.co/t/highlight-works-not-always/19702/2 "2017-07-06T01:03:30Z")

</div>


