# Synonym in Query\_string not working as expected

**URL:** <https://discuss.elastic.co/t/synonym-in-query-string-not-working-as-expected/236269>\
**Category:** Elasticsearch\
**Created:** [June 9, 2020, 6:10am UTC](https://discuss.elastic.co/t/synonym-in-query-string-not-working-as-expected/236269 "2020-06-09T06:10:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lalit\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lalit_kumar/32/48738_2.png) [@Lalit\_Kumar](https://discuss.elastic.co/u/Lalit_Kumar)\
**Post date:** [June 9, 2020, 6:10am UTC](https://discuss.elastic.co/t/synonym-in-query-string-not-working-as-expected/236269/1 "2020-06-09T06:10:06Z")

</div>

Hey, Thank you in advance, any help would be greatly appreciated.  
I am not clear why this happening.

when i execute the given(below) query its return 200. but the synonym created for the query is not correct. so results are not as expected.  
it also exclude the original word from query while creating synonym.

```
"analysis":{

   "filter":{
      "my_multiplexer":{

         "type":"multiplexer",
         "filters":[
            "lowercase",
            "job_title_filter_search",
            "english_stop",
            "porter_stem"
         ]
      },

      "english_stop":{
         "type":"stop",
         "stopwords":"_english_"
      },

      "job_title_filter_search":{
         "type":"synonym_graph",
         "synonyms_path":"synonyms/synonym_job_titles_search_inthensive.txt",
         "updateable":"true"
      }
   },

  "analyzer":{
     
      
     "synonym_analyzer_for_search":{
         "type":"custom",
         "char_filter":[
            "my_char_filter",
            "alphabets_char_filter"
         ],
         "tokenizer":"whitespace",
         "filter":[
            "lowercase",
            "my_multiplexer",
            "remove_duplicates"
         ]
      }
   },

   "char_filter":{
      "my_char_filter":{
         "type":"html_strip",
         "replacement":" "
      },
      "alphabets_char_filter":{
         "pattern":"&nbsp;|[-,/]|&amp;",
         "type":"pattern_replace",
         "replacement":" "
      }
   }
},

```

1. query = "location.address.city:delhi OR location.address.city:noida"

Synonyms in txt file

> <https://gist.github.com/Lalit-001/a74da962e935953b82a2d31635a1408a>

the synonym output

1. if query = "location.address.city:delhi OR location.address.city:noida", it's creating "noida noida"  
(`Synonym(location.address.city:delhi location.address.city:new) location.address.city:delhi location.address.city:\"noida noida\" location.address.city:\"greater noida\" location.address.city:\"gautam buddh nagar\" location.address.city:\"gautam buddh noida\")`

2. if query = "qa", it will remove the qa from query.  
`(title:\"qa assurance\" title:\"quality assurance\" title:assurance title:qc)^4.0`

3. example if query = "qc"  
`(title:\"qc assurance\" title:\"quality assurance\" title:qa title:assurance)^4.0`

---

<div class="post-metadata">

**Author:** ![Lalit\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lalit_kumar/32/48738_2.png) [@Lalit\_Kumar](https://discuss.elastic.co/u/Lalit_Kumar)\
**Post date:** [June 19, 2020, 8:12am UTC](https://discuss.elastic.co/t/synonym-in-query-string-not-working-as-expected/236269/2 "2020-06-19T08:12:10Z")

</div>

solved: don't use multiplexer with synonym\_graph, they are buggy together.

---

<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 17, 2020, 8:12am UTC](https://discuss.elastic.co/t/synonym-in-query-string-not-working-as-expected/236269/3 "2020-07-17T08:12:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
