# Synonym\_filter and edge\_ngram token filter not working together

**URL:** <https://discuss.elastic.co/t/synonym-filter-and-edge-ngram-token-filter-not-working-together/126665>\
**Category:** Elasticsearch\
**Created:** [April 4, 2018, 3:21am UTC](https://discuss.elastic.co/t/synonym-filter-and-edge-ngram-token-filter-not-working-together/126665 "2018-04-04T03:21:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deepak\_r\_kiran](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@Deepak\_r\_kiran](https://discuss.elastic.co/u/Deepak_r_kiran)\
**Post date:** [April 4, 2018, 3:21am UTC](https://discuss.elastic.co/t/synonym-filter-and-edge-ngram-token-filter-not-working-together/126665/1 "2018-04-04T03:21:53Z")

</div>

My index setting -

{  
"settings": {  
"number\_of\_shards": 1,  
"analysis": {  
"filter": {  
"autocomplete\_filter": {  
"type": "edge\_ngram",  
"min\_gram": 1,  
"max\_gram": 50  
},  
"synonym" : {  
"type" : "synonym",  
"synonyms\_path" : "synonym.txt"  
}  
},  
"analyzer": {  
"autocomplete": {  
"type": "custom",  
"tokenizer": "standard",  
"filter": [  
"lowercase",  
"synonym",  
"autocomplete\_filter"  
]  
},  
"search\_synonyms" : {  
"tokenizer" : "standard",  
"filter" : ["synonym"]  
}  
}  
}  
}  
}

Indexing work well but at the time of search If I use autocomplete analyzer it produces synonym results but along with random match

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [April 4, 2018, 3:38am UTC](https://discuss.elastic.co/t/synonym-filter-and-edge-ngram-token-filter-not-working-together/126665/2 "2018-04-04T03:38:06Z")

</div>

Can you explain a bit more and show an example that illustrates your issue? You should also provide your mapping and what you're trying to search? There's probably a logical explanation behind this.

---

<div class="post-metadata">

**Author:** ![Deepak\_r\_kiran](https://avatars.discourse-cdn.com/v4/letter/d/ecccb3/32.png) [@Deepak\_r\_kiran](https://discuss.elastic.co/u/Deepak_r_kiran)\
**Post date:** [April 4, 2018, 6:42am UTC](https://discuss.elastic.co/t/synonym-filter-and-edge-ngram-token-filter-not-working-together/126665/3 "2018-04-04T06:42:00Z")

</div>

As explained in -[https://www.elastic.co/guide/en/elasticsearch/guide/master/\_index\_time\_search\_as\_you\_type.html](https://www.elastic.co/guide/en/elasticsearch/guide/master/_index_time_search_as_you_type.html)

I have created an index with edge-ngram and synonym filter.  
To support synonym at search time I have defined search\_synonyms analyzer.  
query time synonym also work with autocomplete analyzer but it produces a lot verbose result before an exact match  
and defined query time analyser won't work while search\_as\_you\_type it only work with exact match.

---

<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:** [May 2, 2018, 6:42am UTC](https://discuss.elastic.co/t/synonym-filter-and-edge-ngram-token-filter-not-working-together/126665/4 "2018-05-02T06:42:02Z")

</div>

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