# Synonym

**URL:** <https://discuss.elastic.co/t/synonym/12324>\
**Category:** Elasticsearch\
**Created:** [June 8, 2013, 1:33am UTC](https://discuss.elastic.co/t/synonym/12324 "2013-06-08T01:33:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Igal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igal/32/1119_2.png) [@Igal](https://discuss.elastic.co/u/Igal)\
**Post date:** [June 8, 2013, 1:33am UTC](https://discuss.elastic.co/t/synonym/12324/1 "2013-06-08T01:33:06Z")

</div>

hi all --

I'm trying to setup a synonym filter in ES. here's what I did so far:

1. I created a file named elasticsearch.json (and deleted the default  
elasticsearch.yml) with this information:

{  
"index" : {  
"analysis" : {  
"analyzer" : {  
"synonym" : {  
"tokenizer" : "whitespace",  
"filter" : ["synonym"]  
}  
},  
"filter" : {  
"synonym" : {  
"type" : "synonym",  
"synonyms\_path" : "synonym.txt"  
}  
}  
}  
}  
}

1. added a file named synonym.txt in the same folder, with information like:

2. reindexed all data

so now I expect that a (query-string) search for "red candle" and "red  
candles" will return the same results as "candle" and "candles" are  
synonyms but instead I get different results.

what am I doing wrong? and how can I tell which tokens were actually  
indexed?

thanks,

Igal

--  
Igal Sapir  
Railo Core Developer  
[http://getRailo.org/](http://getRailo.org/)

--  
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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 8, 2013, 3:40am UTC](https://discuss.elastic.co/t/synonym/12324/2 "2013-06-08T03:40:05Z")

</div>

1. don't remove yml file. It contains node settings, not index settings.  
Use create index REST API to create your index with your analyzer.
2. if you want to manage plural forms, why not using a stemmer instead?
3. use analyze API to understand how elasticsearch is breaking your strings into tokens.

## HTH

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 8 juin 2013 à 03:33, "Igal @ [getRailo.org](http://getRailo.org)" [igal@getrailo.org](mailto:igal@getrailo.org) a écrit :

> hi all --
> 
> I'm trying to setup a synonym filter in ES. here's what I did so far:
> 
> 1. I created a file named elasticsearch.json (and deleted the default elasticsearch.yml) with this information:
> 
> {  
> "index" : {  
> "analysis" : {  
> "analyzer" : {  
> "synonym" : {  
> "tokenizer" : "whitespace",  
> "filter" : ["synonym"]  
> }  
> },  
> "filter" : {  
> "synonym" : {  
> "type" : "synonym",  
> "synonyms\_path" : "synonym.txt"  
> }  
> }  
> }  
> }  
> }
> 
> 1. added a file named synonym.txt in the same folder, with information like:
> 
> candle, candles  
> candle holder, candle holders  
> tea light, tea lights, tealights
> 
> 1. reindexed all data
> 
> so now I expect that a (query-string) search for "red candle" and "red candles" will return the same results as "candle" and "candles" are synonyms but instead I get different results.
> 
> what am I doing wrong? and how can I tell which tokens were actually indexed?
> 
> thanks,
> 
> Igal
> 
> --  
> Igal Sapir  
> Railo Core Developer  
> [http://getRailo.org/](http://getRailo.org/)
> 
> --  
> 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).

--  
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:** ![Igal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igal/32/1119_2.png) [@Igal](https://discuss.elastic.co/u/Igal)\
**Post date:** [June 9, 2013, 6:40am UTC](https://discuss.elastic.co/t/synonym/12324/3 "2013-06-09T06:40:31Z")

</div>

thanks for the reply.

so I can keep both elasticsearch.yml and elasticsearch.json and they will  
both be read? in what order -- yml first? or are you suggesting that I  
will not use elasticsearch.json at all? I personally don't like yml much  
-- json seems clearer to me.

this is not only for plural so stemming will not work for me.

thanks again,

Igal

On Friday, June 7, 2013 8:40:05 PM UTC-7, David Pilato wrote:

> 1. don't remove yml file. It contains node settings, not index settings.  
> Use create index REST API to create your index with your analyzer.
> 2. if you want to manage plural forms, why not using a stemmer instead?
> 3. use analyze API to understand how elasticsearch is breaking your  
> strings into tokens.
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 8 juin 2013 à 03:33, "Igal @ [getRailo.org](http://getRailo.org)" \<[ig...@getrailo.org](mailto:ig...@getrailo.org)\<javascript:\>\>  
> a écrit :
> 
> > hi all --
> > 
> > I'm trying to setup a synonym filter in ES. here's what I did so far:
> > 
> > 1. I created a file named elasticsearch.json (and deleted the default  
> > elasticsearch.yml) with this information:
> > 
> > {  
> > "index" : {  
> > "analysis" : {  
> > "analyzer" : {  
> > "synonym" : {  
> > "tokenizer" : "whitespace",  
> > "filter" : ["synonym"]  
> > }  
> > },  
> > "filter" : {  
> > "synonym" : {  
> > "type" : "synonym",  
> > "synonyms\_path" : "synonym.txt"  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > 1. added a file named synonym.txt in the same folder, with information  
> > like:
> > 
> > candle, candles  
> > candle holder, candle holders  
> > tea light, tea lights, tealights
> > 
> > 1. reindexed all data
> > 
> > so now I expect that a (query-string) search for "red candle" and "red  
> > candles" will return the same results as "candle" and "candles" are  
> > synonyms but instead I get different results.
> > 
> > what am I doing wrong? and how can I tell which tokens were actually  
> > indexed?
> > 
> > thanks,
> > 
> > Igal
> > 
> > --  
> > Igal Sapir  
> > Railo Core Developer  
> > [http://getRailo.org/](http://getRailo.org/)
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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:32am UTC](https://discuss.elastic.co/t/synonym/12324/4 "2017-07-06T02:32:05Z")

</div>


