# FVH highlights the smallest matching token

**URL:** <https://discuss.elastic.co/t/fvh-highlights-the-smallest-matching-token/54264>\
**Category:** Elasticsearch\
**Created:** [June 29, 2016, 10:53am UTC](https://discuss.elastic.co/t/fvh-highlights-the-smallest-matching-token/54264 "2016-06-29T10:53:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Viola\_Pinto](https://avatars.discourse-cdn.com/v4/letter/v/a8b319/32.png) [@Viola\_Pinto](https://discuss.elastic.co/u/Viola_Pinto)\
**Post date:** [June 29, 2016, 10:53am UTC](https://discuss.elastic.co/t/fvh-highlights-the-smallest-matching-token/54264/1 "2016-06-29T10:53:49Z")

</div>

Settings:  
{  
"settings": {  
"analysis": {  
"analyzer": {  
"idx\_analyzer\_ngram": {  
"type": "custom",  
"filter": [  
"lowercase",  
"asciifolding",  
"edgengram\_filter\_1\_32"  
],  
"tokenizer": "ngram\_alltokenchar\_tokenizer\_1\_32"  
},  
"ngrm\_srch\_analyzer": {  
"filter": [  
"lowercase"  
],  
"type": "custom",  
"tokenizer": "keyword"  
}  
},  
"tokenizer": {  
"ngram\_alltokenchar\_tokenizer\_1\_32": {  
"token\_chars": [  
"letter",  
"whitespace",  
"punctuation",  
"symbol",  
"digit"  
],  
"min\_gram": "1",  
"type": "nGram",  
"max\_gram": "32"  
}  
}  
}  
}  
}

Mappings:  
{  
"properties": {  
"TITLE": {  
"type": "string",  
"fields": {  
"untouched": {  
"index": "not\_analyzed",  
"type": "string"  
},  
"ngramanalyzed": {  
"search\_analyzer": "ngrm\_srch\_analyzer",  
"index\_analyzer": "idx\_analyzer\_ngram",  
"type": "string",  
"term\_vector": "with\_positions\_offsets"  
}  
}  
}  
}  
}

Query:  
{  
"query": {  
"filtered": {  
"query": {  
"query\_string": {  
"query": "have some ha",  
"fields": [  
"TITLE.ngramanalyzed"  
],  
"default\_operator": "and"  
}  
}  
}  
},  
"highlight": {  
"fields": {  
"TITLE.ngramanalyzed": {}  
}  
}  
}

I have document indexed with TITLE **have some happy meal**. When I search **have some** , I am able to get proper highlights.  
**_have_ _some_ happy meal**

As i type more **have some ha** , the highlight results are not as expected.  
**_ha_ve _some_ _ha_ppy meal**

The **have** word gets partially highlighted.

I would expect it to highlight the longest matching token, because with an ngrams with min size = 1, this gives me a highlight of 1 or more char while there should be another matching token of 4 or 5 chars (for example: **have** should also be highlighted along with **ha** being highlighted)

---

<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 5, 2017, 10:39pm UTC](https://discuss.elastic.co/t/fvh-highlights-the-smallest-matching-token/54264/2 "2017-07-05T22:39:36Z")

</div>


