# Help with synonyms and edge ngram analyzers

**URL:** <https://discuss.elastic.co/t/help-with-synonyms-and-edge-ngram-analyzers/7237>\
**Category:** Elasticsearch\
**Created:** [April 5, 2012, 6:32am UTC](https://discuss.elastic.co/t/help-with-synonyms-and-edge-ngram-analyzers/7237 "2012-04-05T06:32:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Tam](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@Dan\_Tam](https://discuss.elastic.co/u/Dan_Tam)\
**Post date:** [April 5, 2012, 6:32am UTC](https://discuss.elastic.co/t/help-with-synonyms-and-edge-ngram-analyzers/7237/1 "2012-04-05T06:32:22Z")

</div>

Hi,

I'm having problems with an analyzer that uses both synonyms and edge  
ngrams filters. I opened an issue on github a few days ago:  
[https://github.com/elasticsearch/elasticsearch/issues/1835](https://github.com/elasticsearch/elasticsearch/issues/1835) .There is  
also a gist to recreate the problem: [https://gist.github.com/2287663](https://gist.github.com/2287663)

When I use an analyzer with edge ngram filter and synonym filter  
during index time, for synonyms defined as "word =\> synonym", "word"  
is not indexed at all.

Depending on the order of how the filters are defined, the behavior is  
different. If the filter list is ["standard", "lowercase", "ngrams",  
"synonym"], "word" would be indexed as "w", "wo", "wor", "synonym". If  
the order of "ngrams" and "synonyms" is reversed, the indexed tokens  
are: "s", "sy", "syn", ... "synony", "word".

Any help is much appreciated.

Thanks,  
Dan

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 8, 2012, 5:56pm UTC](https://discuss.elastic.co/t/help-with-synonyms-and-edge-ngram-analyzers/7237/2 "2012-04-08T17:56:30Z")

</div>

What exactly are you trying to do? Have ngrams applied on the synonyms as  
well? It probably make sense in this case to reverse teh order, and first  
have the synonym filter, and then apply ngram on it.

On Thu, Apr 5, 2012 at 9:32 AM, Dan Tam [dantam@gmail.com](mailto:dantam@gmail.com) wrote:

> Hi,
> 
> I'm having problems with an analyzer that uses both synonyms and edge  
> ngrams filters. I opened an issue on github a few days ago:  
> [synonym removed ngram entry? · Issue #1835 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1835) .There is  
> also a gist to recreate the problem: [ElasticSearch difficulties with edge ngram and synonym analyzer · GitHub](https://gist.github.com/2287663)
> 
> When I use an analyzer with edge ngram filter and synonym filter  
> during index time, for synonyms defined as "word =\> synonym", "word"  
> is not indexed at all.
> 
> Depending on the order of how the filters are defined, the behavior is  
> different. If the filter list is ["standard", "lowercase", "ngrams",  
> "synonym"], "word" would be indexed as "w", "wo", "wor", "synonym". If  
> the order of "ngrams" and "synonyms" is reversed, the indexed tokens  
> are: "s", "sy", "syn", ... "synony", "word".
> 
> Any help is much appreciated.
> 
> Thanks,  
> Dan

---

<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 6, 2017, 3:33am UTC](https://discuss.elastic.co/t/help-with-synonyms-and-edge-ngram-analyzers/7237/3 "2017-07-06T03:33:15Z")

</div>


