# Elk highlight synonym problem

**URL:** <https://discuss.elastic.co/t/elk-highlight-synonym-problem/222399>\
**Category:** Elasticsearch\
**Created:** [March 6, 2020, 3:04am UTC](https://discuss.elastic.co/t/elk-highlight-synonym-problem/222399 "2020-03-06T03:04:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ye\_Zetao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ye_zetao/32/63930_2.png) [@Ye\_Zetao](https://discuss.elastic.co/u/Ye_Zetao)\
**Post date:** [March 6, 2020, 3:04am UTC](https://discuss.elastic.co/t/elk-highlight-synonym-problem/222399/1 "2020-03-06T03:04:24Z")

</div>

Hi, I am using elasticsearch 6.x version and I have problem when gettiing highlight result with synonym.

```auto
PUT /my_test_index/
{
    "settings": {
        "analysis": {
            "filter": {
                "native_synonym": {
                    "type": "synonym",
                    "ignore_case": true,
                    "expand": true,
                    "synonyms": [
                        "apple,fruit"
                    ]
                }
            },
            "analyzer": {
                "test_analyzer": {
                    "tokenizer": "whitespace",
                    "filter": [
                        "native_synonym"
                    ]
                }
            }
        }
    },
    "mappings": {
        "properties": {
            "desc": {
                "type": "text",
                "analyzer": "test_analyzer"
            }
        }
    }
}

```

when I search keywords `apple` with `desc` fields highlight

```auto
{
    "query": {
    	"match": {
    		"desc": "apple"
    	}
    },
    "highlight": {
    	"fields": {
    		"desc": {}
    	}
    }
}

```

I got both `apple` and `fruit` highlight, however I only want the words `apple` highlight because what I search in the query is the word `apple`

```auto
"hits": [
            {
                "_index": "my_test_index",
                "_type": "_doc",
                "_id": "RMyZrXAB7JsJEwsbVF33",
                "_score": 0.29171452,
                "_source": {
                    "desc": "apple"
                },
                "highlight": {
                    "desc": [
                        "<em>apple</em>"
                    ]
                }
            },
            {
                "_index": "my_test_index",
                "_type": "_doc",
                "_id": "RcyarXAB7JsJEwsboF2V",
                "_score": 0.29171452,
                "_source": {
                    "desc": "fruit"
                },
                "highlight": {
                    "desc": [
                        "<em>fruit</em>"
                    ]
                }
            }
        ]

```

Anyone knows how to solve this? Thanks in advance.

---

<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:** [April 3, 2020, 3:04am UTC](https://discuss.elastic.co/t/elk-highlight-synonym-problem/222399/2 "2020-04-03T03:04:24Z")

</div>

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