# Synonym Filter

**URL:** <https://discuss.elastic.co/t/synonym-filter/15321>\
**Category:** Elasticsearch\
**Created:** [January 20, 2014, 12:47pm UTC](https://discuss.elastic.co/t/synonym-filter/15321 "2014-01-20T12:47:52Z")\
**Posts on this page:** 3\
**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:** [January 20, 2014, 12:47pm UTC](https://discuss.elastic.co/t/synonym-filter/15321/1 "2014-01-20T12:47:52Z")

</div>

Hi,

My Synonym file contains the entry as below

MIT,Massachusetts Institute of Technology

My setting is as below:

"settings":{  
"analysis":{  
"analyzer":{  
"synonym":{  
"tokenizer":"my\_pipe\_analyzer",  
"filter":[  
"lowercase",  
"syns\_filter"  
]  
},  
"my\_pipe\_analyzer":{  
"tokenizer":"my\_pipe\_analyzer"  
},  
"autocomplete\_search":{  
"type":"custom",  
"tokenizer":"my\_pipe\_analyzer",  
"filter":[  
"lowercase",  
"syns\_filter",  
"stop"  
]  
}  
},  
"tokenizer":{  
"my\_pipe\_analyzer":{  
"type":"pattern",  
"pattern":"\|"  
}  
},  
"filter":{  
"syns\_filter":{  
"synonyms\_path":"synonyms/synonym\_collegename.txt",  
"type":"synonym",  
"ignore\_case":true  
}  
}  
}  
}

I have created a pipe separated tokanizer so that the synonyms are not  
split on spaces still it is getting split on spaces when i verify it with  
the analyze API , below is my output from  
analyzer api.

{  
"tokens":[  
{  
"token":"mit",  
"start\_offset":0,  
"end\_offset":3,  
"type":"SYNONYM",  
"position":1  
},  
{  
"token":"massachusetts",  
"start\_offset":0,  
"end\_offset":3,  
"type":"SYNONYM",  
"position":1  
},  
{  
"token":"institute",  
"start\_offset":0,  
"end\_offset":3,  
"type":"SYNONYM",  
"position":2  
},  
{  
"token":"technology",  
"start\_offset":0,  
"end\_offset":3,  
"type":"SYNONYM",  
"position":4  
}  
]  
}

--  
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/7516d1a7-72d0-4b3f-b426-deb80b8d6450%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7516d1a7-72d0-4b3f-b426-deb80b8d6450%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:** ![sina\_tamanna](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@sina\_tamanna](https://discuss.elastic.co/u/sina_tamanna)\
**Post date:** [January 21, 2014, 8:09am UTC](https://discuss.elastic.co/t/synonym-filter/15321/2 "2014-01-21T08:09:52Z")

</div>

Hey,

Synonym filter has its own tokenizer which is not the same as one defined  
for synonym analyzer. You need to define the tokenizer inside the synonym  
filter:

"filter":{  
"syns\_filter":{  
"synonyms\_path":"synonyms/synonym\_collegename.txt",  
"type":"synonym",  
"tokenizer":"keyword",  
"ignore\_case":true  
}  
}

--  
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/3390e6e4-5f0e-448a-bcc2-e3385200731b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3390e6e4-5f0e-448a-bcc2-e3385200731b%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:** ![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, 1:55am UTC](https://discuss.elastic.co/t/synonym-filter/15321/3 "2017-07-06T01:55:44Z")

</div>


