# Generate synonyms on indexation side or on search side?

**URL:** <https://discuss.elastic.co/t/generate-synonyms-on-indexation-side-or-on-search-side/12944>\
**Category:** Elasticsearch\
**Created:** [July 25, 2013, 4:42pm UTC](https://discuss.elastic.co/t/generate-synonyms-on-indexation-side-or-on-search-side/12944 "2013-07-25T16:42:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olivier\_Revollat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olivier_revollat/32/1467_2.png) [@Olivier\_Revollat](https://discuss.elastic.co/u/Olivier_Revollat)\
**Post date:** [July 25, 2013, 4:42pm UTC](https://discuss.elastic.co/t/generate-synonyms-on-indexation-side-or-on-search-side/12944/1 "2013-07-25T16:42:47Z")

</div>

I want to use synonyms tokens filter ...  
but I wonder if I have to "generate" my synonyms on the indexation side or  
on the search side :

I go for :

index like this :  
stop\_words -\> lowercase -\> synonyms -\> stemmer -\> asciifolder

and parse search like this :  
stop\_words -\> lowercase -\> humspell -\> stemmer -\> asciifolder

So, do I have to "generate" synonyms" on indexing or on the "search side" ?  
I go for generating synonyms while indexing ... but I prefer to ask ... 😉

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [July 26, 2013, 9:30am UTC](https://discuss.elastic.co/t/generate-synonyms-on-indexation-side-or-on-search-side/12944/2 "2013-07-26T09:30:14Z")

</div>

Hi,

I tend to prefer indexing-time synonyms. If you only apply synonyms at  
searching time then there will be a bias in the score that will favor the  
documents that contain the least frequent synonyms because of their IDF.  
For example, if television and TV are synonyms and if "television" is much  
more frequent than "TV" in your index, searching for "TV" or "television"  
will make documents which contain "TV" appear first in the results.

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [July 26, 2013, 9:22pm UTC](https://discuss.elastic.co/t/generate-synonyms-on-indexation-side-or-on-search-side/12944/3 "2013-07-26T21:22:09Z")

</div>

Yeah, from my experiences, I agree. Index time synonyms while not as  
flexible (need to rebuild if it changes) ends up with much better  
experience.

Only do the expansion on the index analyzer, not the search analyzer for  
the field.

Best Regards,  
Paul

On Friday, July 26, 2013 3:30:14 AM UTC-6, Adrien Grand wrote:

> Hi,
> 
> I tend to prefer indexing-time synonyms. If you only apply synonyms at  
> searching time then there will be a bias in the score that will favor the  
> documents that contain the least frequent synonyms because of their IDF.  
> For example, if television and TV are synonyms and if "television" is much  
> more frequent than "TV" in your index, searching for "TV" or "television"  
> will make documents which contain "TV" appear first in the results.
> 
> --  
> Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Olivier\_Revollat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olivier_revollat/32/1467_2.png) [@Olivier\_Revollat](https://discuss.elastic.co/u/Olivier_Revollat)\
**Post date:** [July 27, 2013, 11:49am UTC](https://discuss.elastic.co/t/generate-synonyms-on-indexation-side-or-on-search-side/12944/4 "2013-07-27T11:49:06Z")

</div>

thanks guys !

2013/7/26 ppearcy [ppearcy@gmail.com](mailto:ppearcy@gmail.com)

> Yeah, from my experiences, I agree. Index time synonyms while not as  
> flexible (need to rebuild if it changes) ends up with much better  
> experience.
> 
> Only do the expansion on the index analyzer, not the search analyzer for  
> the field.
> 
> Best Regards,  
> Paul
> 
> On Friday, July 26, 2013 3:30:14 AM UTC-6, Adrien Grand wrote:
> 
> > Hi,
> > 
> > I tend to prefer indexing-time synonyms. If you only apply synonyms at  
> > searching time then there will be a bias in the score that will favor the  
> > documents that contain the least frequent synonyms because of their IDF.  
> > For example, if television and TV are synonyms and if "television" is much  
> > more frequent than "TV" in your index, searching for "TV" or "television"  
> > will make documents which contain "TV" appear first in the results.
> > 
> > --  
> > Adrien Grand
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/DFYxLBzPwqw/unsubscribe](https://groups.google.com/d/topic/elasticsearch/DFYxLBzPwqw/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--

"Si les gens ne croient pas que les mathématiques sont simples, c’est  
uniquement parce qu’ils ne réalisent pas à quel point la vie est  
compliquée."

- John von Neumann

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:24am UTC](https://discuss.elastic.co/t/generate-synonyms-on-indexation-side-or-on-search-side/12944/5 "2017-07-06T02:24:09Z")

</div>


