# Highlighting is not working as expected with synonym wordnet filter in elasticsearch

**URL:** <https://discuss.elastic.co/t/highlighting-is-not-working-as-expected-with-synonym-wordnet-filter-in-elasticsearch/149455>\
**Category:** Elasticsearch\
**Created:** [September 21, 2018, 12:48pm UTC](https://discuss.elastic.co/t/highlighting-is-not-working-as-expected-with-synonym-wordnet-filter-in-elasticsearch/149455 "2018-09-21T12:48:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashwin\_rao](https://avatars.discourse-cdn.com/v4/letter/a/34f0e0/32.png) [@ashwin\_rao](https://discuss.elastic.co/u/ashwin_rao)\
**Post date:** [September 21, 2018, 12:48pm UTC](https://discuss.elastic.co/t/highlighting-is-not-working-as-expected-with-synonym-wordnet-filter-in-elasticsearch/149455/1 "2018-09-21T12:48:16Z")

</div>

Hi Guys,  
I am facing some issue in highlighting synonyms which are mapped from Wordnet. It is highlighting irrelevant words while searching.

Here's my code below.

{  
"settings" : {  
"index" : {  
"analysis" : {  
"analyzer" : {  
"synonym" : {  
"tokenizer" : "standard",  
"filter" : ["synonym","lowercase"]  
}  
},  
"filter" : {  
"synonym" : {  
"type": "synonym",  
"format" : "wordnet",  
"synonyms\_path": "analysis/wn\_s.pl"  
}  
}  
}  
}  
},  
"mappings": {  
"header": {  
"properties": {  
"test\_string": {  
"type": "text",  
"analyzer": "synonym",  
"term\_vector": "with\_positions\_offsets"  
}  
}  
}  
}  
}

My search query .  
{"query": { "query\_string": { "query": "info~" }},"highlight": {"pre\_tags": [""],"post\_tags": [""],"fields" : {"test\_string":{}},"fragment\_size" :501, "number\_of\_fragments" : 1}}

Results are as below.

TEST: This area contains the Customer name: TEST Customer Type TEST: This area contains **information** on the type: TEST DLA

Note : Please click ' **new** value' column and 'old value' column on the Contract Header page to view complete values.

Note: Transaction report present on Header display only partial value, user need to click ' **Old** Value' and 'New Value' to view complete.

In the above results , i wanted only "information" to be highlighted , but its highlighting "new" and "old" text. I also analysed the token output and find that it is working as expected but highlight is causing problem.

Elasticsearch version - 6.2.4

Please suggest where I am going wrong. Thanks.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [September 28, 2018, 9:13am UTC](https://discuss.elastic.co/t/highlighting-is-not-working-as-expected-with-synonym-wordnet-filter-in-elasticsearch/149455/2 "2018-09-28T09:13:19Z")

</div>

> [@ashwin\_rao](#):
>
> analysis/wn\_s.pl

Can you add the synonym file or tell me where you got it from? I'd help recreate the issue.

---

<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:** [October 26, 2018, 9:13am UTC](https://discuss.elastic.co/t/highlighting-is-not-working-as-expected-with-synonym-wordnet-filter-in-elasticsearch/149455/3 "2018-10-26T09:13:21Z")

</div>

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