# Expected result with highlighter in analyzed data

**URL:** <https://discuss.elastic.co/t/expected-result-with-highlighter-in-analyzed-data/31359>\
**Category:** Elasticsearch\
**Created:** [September 29, 2015, 5:55pm UTC](https://discuss.elastic.co/t/expected-result-with-highlighter-in-analyzed-data/31359 "2015-09-29T17:55:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pgnrk23](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pgnrk23/32/5636_2.png) [@pgnrk23](https://discuss.elastic.co/u/pgnrk23)\
**Post date:** [September 29, 2015, 5:55pm UTC](https://discuss.elastic.co/t/expected-result-with-highlighter-in-analyzed-data/31359/1 "2015-09-29T17:55:40Z")

</div>

I have indexed my data using few analyzers. Everything is fine. When I try to search the data using particular keyword, the analyzed result brings me the proper data. But the applied highlighter brings me only the exact matches.  
For example, I've the indexed data like " a cat stalking a bird " so when I try to search " talking ", I see the above data appear in the result but not in the highlighted field.

Settings

```
{
	"index": {
		"analysis": {
			"analyzer": {
				"summary_analyzer": {
					"type": "custom",
					"char_filter": "html_strip",
					"tokenizer": "standard",
					"filter": ["standard",
					"loweritem",
					"mynGram"],
					"stopwords": "_english_"
				},
				"my_ngram_analyzer": {
					"type": "custom",
					"tokenizer": "my_ngram_tokenizer",
					"filter": ["standard",
					"loweritem"],
					"stopwords": "_english_"
				},
				"snowball_analyzer": {
					"type": "snowball",
					"language": "English",
					"stopwords": "_english_"
				},
				"loweritem_analyzer": {
					"type": "custom",
					"tokenizer": "keyword",
					"filter": ["loweritem"]
				},
				"shingle_analyzer": {
					"type": "custom",
					"tokenizer": "standard",
					"filter": ["myShingle"]
				},
				"entityReverse": {
					"type": "custom",
					"tokenizer": "keyword",
					"filter": "reverse"
				}
			},
			"filter": {
				"mynGram": {
					"type": "nGram",
					"min_gram": 2,
					"max_gram": 50,
					"token_chars": ["letter",
					"digit",
					"symbol",
					"punctuation"]
				},
				"myShingle": {
					"type": "shingle",
					"min_shingle_size": 2,
					"max_shingle_size": 2
				}
			},
			"tokenizer": {
				"my_ngram_tokenizer": {
					"type": "nGram",
					"min_gram": "2",
					"max_gram": "50",
					"token_chars": ["letter",
					"digit",
					"symbol",
					"punctuation"]
				}
			}
		}
	}
}

```

Query

```
{
	"from": 0,
	"size": 15,
	"query": {
		"filtered": {
			"query": {
				"bool": {
					"must": {
						"nested": {
							"query": {
								"match": {
									"items.isDeleted": {
										"query": 0,
										"type": "boolean"
									}
								}
							},
							"path": "items"
						}
					},
					"should": [{
						"nested": {
							"query": {
								"multi_match": {
									"query": "talking",
									"fields": ["items.itemTitle.raw^5",
									"items.itemTitle.my_ngram_title^3.5",
									"items.itemTitle.snowball_title^4",
									"items.itemTitle.loweritem_title^4"],
									"type": "phrase"
								}
							},
							"path": "items"
						}
					},
					{
						"nested": {
							"query": {
								"multi_match": {
									"query": "talking",
									"fields": ["itemSummary.summary.raw^1.5",
									"itemSummary.summary.analyzed_summary^0.5",
									"itemSummary.summary.snowball_summary"],
									"type": "phrase"
								}
							},
							"path": "itemSummary"
						}
					},
					{
						"match": {
							"items.itemId": {
								"query": "talking",
								"type": "boolean"
							}
						}
					}],
					"minimum_should_match": "2"
				}
			},
			"filter": {
				"or": {
					"filters": [{
						"term": {
							"roles": 1
						}
					},
					{
						"term": {
							"users": 327
						}
					}]
				}
			}
		}
	},
	"fields": ["*",
	"_source"],
	"sort": [{
		"items.isNotDraft": {
			"order": "asc",
			"mode": "min"
		}
	},
	{
		"_score": {
			
		}
	}],
	"highlight": {
		"fields": {
			*: {
				
			}
		}
	}
}
```

---

<div class="post-metadata">

**Author:** ![pgnrk23](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pgnrk23/32/5636_2.png) [@pgnrk23](https://discuss.elastic.co/u/pgnrk23)\
**Post date:** [September 29, 2015, 5:56pm UTC](https://discuss.elastic.co/t/expected-result-with-highlighter-in-analyzed-data/31359/2 "2015-09-29T17:56:18Z")

</div>

Search Result

```
{
	"took": 53,
	"timed_out": false,
	"_shards": {
		"total": 5,
		"successful": 5,
		"failed": 0
	},
	"hits": {
		"total": 45,
		"max_score": null,
		"hits": [{
			"_index": "item",
			"_type": "itemdetails",
			"_id": "2fa5cba7435a9de83e8c838c5d602ee0",
			"_score": 1.6257544,
			"_source": {
				"items": {
					"idItem": "2fa5cba7435a9de83e8c838c5d602ee0",
					"itemTitle": "Talk to manager"
				},
				"itemsummary": {
					"idItemsummary": 7072,
					"summary": "While <em>talking</em> with HR she stated that at the"
				},
				"roles": [1,
				2,
				3],
				"users": [111]
			},
			"highlight": {
				"itemsummary.summary": ["While <em>talking</em> with HR she stated that at the"]
			},
			"sort": [1,
			1.6257544]
		},
		{
			"_index": "item",
			"_type": "itemdetails",
			"_id": "2fa5cba7435a9de83e8c838c5d602ee0",
			"_score": 1.6257544,
			"_source": {
				"items": {
					"idItem": "2fa5cba7435a9de83e8c838c5d602ee0",
					"itemTitle": "Stalking"
				},
				"itemsummary": {
					"idItemsummary": 7072,
					"summary": "Nothing"
				},
				"roles": [1,
				2,
				3],
				"users": [111]
			},
			"sort": [1,
			1.6257544]
		}]
	}
}
```

---

<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, 11:47pm UTC](https://discuss.elastic.co/t/expected-result-with-highlighter-in-analyzed-data/31359/3 "2017-07-05T23:47:31Z")

</div>

Closed on July 5, 2017, 11:47pm UTC


