# Synonyms are giving incorrect results when querying?

**URL:** <https://discuss.elastic.co/t/synonyms-are-giving-incorrect-results-when-querying/21189>\
**Category:** Elasticsearch\
**Created:** [December 10, 2014, 1:56pm UTC](https://discuss.elastic.co/t/synonyms-are-giving-incorrect-results-when-querying/21189 "2014-12-10T13:56:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arpit\_tak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arpit_tak/32/1060_2.png) [@arpit\_tak](https://discuss.elastic.co/u/arpit_tak)\
**Post date:** [December 10, 2014, 1:56pm UTC](https://discuss.elastic.co/t/synonyms-are-giving-incorrect-results-when-querying/21189/1 "2014-12-10T13:56:21Z")

</div>

Not able to get proper results only in case of Delhi and india , rest are  
giving proper results.  
#####################  
_Schema :_

curl -XPUT "[http://localhost:9200/sun](http://localhost:9200/sun)" -d'  
{  
'settings': {  
"index": {  
"analysis" : {  
"analyzer" : {  
"my\_search\_analyzer" : {  
"tokenizer" : "whitespace",  
"filter" : ["standard", "asciifolding", "lowercase", "kstem",  
"search\_synonym"]  
}  
},  
"filter" : {  
"search\_synonym" : {  
"type" : "synonym",  
"expand" : true,  
"synonyms\_path" : "analysis/synonym.txt"  
}  
}  
}  
}  
},  
"mappings": {  
"deal": {  
"properties": {  
"description": {  
"type": "string",  
"index\_analyzer": "standard",  
"search\_analyzer": "my\_search\_analyzer"  
}  
}  
}  
}  
}'

##########################

_Sample Data Inserted:_

curl -XPOST "[http://localhost:9200/sun/deal](http://localhost:9200/sun/deal)" -d'  
{  
"description": "Delhi is getting polluted day by day."  
}'

curl -XPOST "[http://localhost:9200/sun/deal](http://localhost:9200/sun/deal)" -d'  
{  
"description": "New delhi is capital of india ."  
}'  
curl -XPOST "[http://localhost:9200/sun/deal](http://localhost:9200/sun/deal)" -d'  
{  
"description": "rajiv chowk is located in the heart of city."  
}'  
curl -XPOST "[http://localhost:9200/sun/deal](http://localhost:9200/sun/deal)" -d'  
{  
"description": "new delhi is a great place to visit."  
}'

curl -XPOST "[http://localhost:9200/sun/deal](http://localhost:9200/sun/deal)" -d'  
{  
"description": "county india is getting polluted day by day ."  
}'

curl -XPOST "[http://localhost:9200/sun/deal](http://localhost:9200/sun/deal)" -d'  
{  
"description": "Delhi is getting polluted day by day now ."  
}'

#######################  
\*synonym.txt \*

delhi =\> delhi,new delhi,rajiv chowk,india  
india =\> delhi,new delhi,rajiv chowk,india  
rajiv chowk =\> delhi,new delhi,rajiv chowk,delhi,india  
new delhi =\> delhi,new delhi,rajiv chowk,india

_Query:_  
curl -XPOST "[http://localhost:9200/sun/\_search?pretty](http://localhost:9200/sun/_search?pretty)" -d'  
{  
"query": {  
"match\_phrase": {  
"description": "india"  
}  
}  
}'

This query is not returning india and delhi in results

whereas keywords like new delhi , rajiv chowk are giving correct results ..

Anyidea whats wrong is happening in above query ??

--  
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/2eb2e8aa-e3e0-40c6-b4a3-f10b1e374122%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2eb2e8aa-e3e0-40c6-b4a3-f10b1e374122%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, 12:44am UTC](https://discuss.elastic.co/t/synonyms-are-giving-incorrect-results-when-querying/21189/2 "2017-07-06T00:44:27Z")

</div>


