# Use Elasticsearch synonym filter to retrieving rows with synonym rule defined

**URL:** <https://discuss.elastic.co/t/use-elasticsearch-synonym-filter-to-retrieving-rows-with-synonym-rule-defined/17311>\
**Category:** Elasticsearch\
**Created:** [May 1, 2014, 11:58pm UTC](https://discuss.elastic.co/t/use-elasticsearch-synonym-filter-to-retrieving-rows-with-synonym-rule-defined/17311 "2014-05-01T23:58:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yang\_Beaty](https://avatars.discourse-cdn.com/v4/letter/y/35a633/32.png) [@Yang\_Beaty](https://discuss.elastic.co/u/Yang_Beaty)\
**Post date:** [May 1, 2014, 11:58pm UTC](https://discuss.elastic.co/t/use-elasticsearch-synonym-filter-to-retrieving-rows-with-synonym-rule-defined/17311/1 "2014-05-01T23:58:29Z")

</div>

Hi,

I am digging into Elasticsearch for a feasibility study, I would like to  
see if elasticsearch's synonym filter could help pick up rows of data that  
share similar wording in a column.

I have implemented a simple prototype

1. I have downloaded accounts.json from elasticsearch.org
2. I placed synonym.txt to the config directory under elasticsearch install  
with one line content as following  
Dona=\>Dale
3. modified an online example from "Rafat Kuc-3" to as following:  
curl -XPOST 'localhost:9200/bank/account' -d '  
{  
"settings": {  
"index" : {  
"analysis" : {  
"analyzer" : {  
"synonym" : {  
"tokenizer" : "whitespace",  
"filter" : ["synonym"]  
}  
},  
"filter" : {  
"synonym" : {  
"type" : "synonym",  
"synonyms\_path" : "synonym.txt"  
}  
}  
}  
}  
},  
"mappings" : {  
"account" : {  
"properties" : {  
"firstname" : { "type" : "string", "index" : "analyzed", "analyzer" :  
"synonym" }  
}  
}  
}  
}'

this is successful!

1. load accounts data with  
curl -XPOST 'localhost:9200/bank/account/\_bulk?pretty' --data-binary  
@accounts.json

this is also successful

Problem I have is: I tried to use elasticsearch/\_plugin/head to search  
giving account.firstname (query string) equals to "Dale", hope to get back  
two rows, with firstname "Dale" and "Dona". But I only get one row back.  
Can someone tell me if I am missing anything to have the synonym filter  
works correctly?  
I see that the pluggin head has a query function such as "fuzzy", and it  
returns rows with "Hale" and "Dale", where is the rule defined and how can  
I insert my own rule?

--  
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/57a04c5d-7a90-4390-b537-08f460e35880%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/57a04c5d-7a90-4390-b537-08f460e35880%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:32am UTC](https://discuss.elastic.co/t/use-elasticsearch-synonym-filter-to-retrieving-rows-with-synonym-rule-defined/17311/2 "2017-07-06T01:32:13Z")

</div>


