# Synonym behavior

**URL:** <https://discuss.elastic.co/t/synonym-behavior/14810>\
**Category:** Elasticsearch\
**Created:** [December 11, 2013, 9:39am UTC](https://discuss.elastic.co/t/synonym-behavior/14810 "2013-12-11T09:39:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)\
**Post date:** [December 11, 2013, 9:39am UTC](https://discuss.elastic.co/t/synonym-behavior/14810/1 "2013-12-11T09:39:22Z")

</div>

My synonym.txt contains the below entry

wfu, sso, united search

Now i indexed a field  
{  
"name":"sso"  
}

when i search as "united search" OR "united" OR "search" it gives sso as  
the result , below is a sample query  
{  
"query": {  
"match": {  
"name": "search"  
}  
}  
}

Now i update synonym.txt file with "Help Me" and restart the node . so  
the synonym.txt content will become  
wfu, sso, united search, Help Me  
Now if i search for "Help" OR "Me" no results but if i search for "Help Me"  
will get sso as result. why??  
I should get result on "Help" OR "Me" also Since its a query time analysis  
, the below query returns no results  
{  
"query": {  
"match": {  
"name": "Help"  
}  
}  
}

My mapping, settings is as below

{  
"settings": {  
"analysis": {  
"analyzer": {  
"synonym": {  
"tokenizer": "whitespace",  
"filter": [  
"standard",  
"lowercase",  
"syns\_filter"  
]  
}  
},  
"filter": {  
"syns\_filter": {  
"synonyms\_path": "synonyms/synonym\_country.txt",  
"type": "synonym"  
}  
}  
}  
},  
"mappings": {  
"hometwo": {  
"properties": {  
"name": {  
"type": "string",  
"analyzer": "synonym"  
}  
}  
}  
}  
}

ElasticSearch version 0.90.0

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/56e7f43a-7e7b-4a96-a107-9dade8c513f1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/56e7f43a-7e7b-4a96-a107-9dade8c513f1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [December 11, 2013, 5:59pm UTC](https://discuss.elastic.co/t/synonym-behavior/14810/2 "2013-12-11T17:59:09Z")

</div>

Note that your filter chain has the synonym filter after the lowercase  
filter. The terms that are passed through the analyzer will be lowercased,  
but no match will be found in the synonym map if the terms are also not  
lowercased. Not sure if this scenario is your problem, but try  
setting ignore\_case to true in synonym filter or use only lowercased terms.

Cheers,

Ivan

On Wed, Dec 11, 2013 at 1:39 AM, paul [avinashpaul85@gmail.com](mailto:avinashpaul85@gmail.com) wrote:

> My synonym.txt contains the below entry
> 
> wfu, sso, united search
> 
> Now i indexed a field  
> {  
> "name":"sso"  
> }
> 
> when i search as "united search" OR "united" OR "search" it gives sso as  
> the result , below is a sample query  
> {  
> "query": {  
> "match": {  
> "name": "search"  
> }  
> }  
> }
> 
> Now i update synonym.txt file with "Help Me" and restart the node . so  
> the synonym.txt content will become  
> wfu, sso, united search, Help Me  
> Now if i search for "Help" OR "Me" no results but if i search for "Help  
> Me" will get sso as result. why??  
> I should get result on "Help" OR "Me" also Since its a query time analysis  
> , the below query returns no results  
> {  
> "query": {  
> "match": {  
> "name": "Help"  
> }  
> }  
> }
> 
> My mapping, settings is as below
> 
> {  
> "settings": {  
> "analysis": {  
> "analyzer": {  
> "synonym": {  
> "tokenizer": "whitespace",  
> "filter": [  
> "standard",  
> "lowercase",  
> "syns\_filter"  
> ]  
> }  
> },  
> "filter": {  
> "syns\_filter": {  
> "synonyms\_path": "synonyms/synonym\_country.txt",  
> "type": "synonym"  
> }  
> }  
> }  
> },  
> "mappings": {  
> "hometwo": {  
> "properties": {  
> "name": {  
> "type": "string",  
> "analyzer": "synonym"  
> }  
> }  
> }  
> }  
> }
> 
> Elasticsearch version 0.90.0
> 
> --  
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/56e7f43a-7e7b-4a96-a107-9dade8c513f1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/56e7f43a-7e7b-4a96-a107-9dade8c513f1%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQD8OzVG70ymQrUz8cQWrsDhoTVqQq-MOkVrEcQv%2BJ\_7ag%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQD8OzVG70ymQrUz8cQWrsDhoTVqQq-MOkVrEcQv%2BJ_7ag%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![paul1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul1/32/46819_2.png) [@paul1](https://discuss.elastic.co/u/paul1)\
**Post date:** [December 12, 2013, 4:33am UTC](https://discuss.elastic.co/t/synonym-behavior/14810/3 "2013-12-12T04:33:03Z")

</div>

Thank you for the reply , I even tried lower case but its still the same  
behavior.

- Paul

On Wed, Dec 11, 2013 at 11:29 PM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> Note that your filter chain has the synonym filter after the lowercase  
> filter. The terms that are passed through the analyzer will be lowercased,  
> but no match will be found in the synonym map if the terms are also not  
> lowercased. Not sure if this scenario is your problem, but try  
> setting ignore\_case to true in synonym filter or use only lowercased terms.
> 
> Cheers,
> 
> Ivan
> 
> On Wed, Dec 11, 2013 at 1:39 AM, paul [avinashpaul85@gmail.com](mailto:avinashpaul85@gmail.com) wrote:
> 
> > My synonym.txt contains the below entry
> > 
> > wfu, sso, united search
> > 
> > Now i indexed a field  
> > {  
> > "name":"sso"  
> > }
> > 
> > when i search as "united search" OR "united" OR "search" it gives sso as  
> > the result , below is a sample query  
> > {  
> > "query": {  
> > "match": {  
> > "name": "search"  
> > }  
> > }  
> > }
> > 
> > Now i update synonym.txt file with "Help Me" and restart the node . so  
> > the synonym.txt content will become  
> > wfu, sso, united search, Help Me  
> > Now if i search for "Help" OR "Me" no results but if i search for "Help  
> > Me" will get sso as result. why??  
> > I should get result on "Help" OR "Me" also Since its a query time  
> > analysis , the below query returns no results  
> > {  
> > "query": {  
> > "match": {  
> > "name": "Help"  
> > }  
> > }  
> > }
> > 
> > My mapping, settings is as below
> > 
> > {  
> > "settings": {  
> > "analysis": {  
> > "analyzer": {  
> > "synonym": {  
> > "tokenizer": "whitespace",  
> > "filter": [  
> > "standard",  
> > "lowercase",  
> > "syns\_filter"  
> > ]  
> > }  
> > },  
> > "filter": {  
> > "syns\_filter": {  
> > "synonyms\_path": "synonyms/synonym\_country.txt",  
> > "type": "synonym"  
> > }  
> > }  
> > }  
> > },  
> > "mappings": {  
> > "hometwo": {  
> > "properties": {  
> > "name": {  
> > "type": "string",  
> > "analyzer": "synonym"  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > Elasticsearch version 0.90.0
> > 
> > --  
> > 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).
> > 
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/56e7f43a-7e7b-4a96-a107-9dade8c513f1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/56e7f43a-7e7b-4a96-a107-9dade8c513f1%40googlegroups.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 a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/HF771t7ocf8/unsubscribe](https://groups.google.com/d/topic/elasticsearch/HF771t7ocf8/unsubscribe).  
> To unsubscribe from this group and all its topics, send an email to  
> [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQD8OzVG70ymQrUz8cQWrsDhoTVqQq-MOkVrEcQv%2BJ\_7ag%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQD8OzVG70ymQrUz8cQWrsDhoTVqQq-MOkVrEcQv%2BJ_7ag%40mail.gmail.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAO066G2WORTnynRLSRUihZgqbsXLFopr9-3JJHtKfeQU-zX-Ug%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAO066G2WORTnynRLSRUihZgqbsXLFopr9-3JJHtKfeQU-zX-Ug%40mail.gmail.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:01am UTC](https://discuss.elastic.co/t/synonym-behavior/14810/4 "2017-07-06T02:01:48Z")

</div>


