# Synonyms not getting applied

**URL:** <https://discuss.elastic.co/t/synonyms-not-getting-applied/215366>\
**Category:** Elasticsearch\
**Created:** [January 16, 2020, 5:40pm UTC](https://discuss.elastic.co/t/synonyms-not-getting-applied/215366 "2020-01-16T17:40:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adityaPsl](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@adityaPsl](https://discuss.elastic.co/u/adityaPsl)\
**Post date:** [January 16, 2020, 5:40pm UTC](https://discuss.elastic.co/t/synonyms-not-getting-applied/215366/1 "2020-01-16T17:40:22Z")

</div>

Hello Team,

I have below document in the index

```
{
  
  "name" :"test",
  "products": [
      {
        "pname" : "p1",
        "qty" : "10 pcs"
      },
      {
        "pname" : " p3 ",
        "qty" : "10 PCS"
       
      }
 ]
}

```

and i have below index settings

```
PUT /tst
{
    "settings": {
        "index" : {
            "analysis" : {
                "analyzer" : {
                    "synonym" : {
                        "tokenizer" : "standard",
                        "filter" : ["synonym"]
                    }
                },
                "filter" : {
                    "synonym" : {
                        "type" : "synonym",
                        "lenient": true,
                        "synonyms" : ["pcs,PCS => piece"]
                    }
                }
            }
        }
    }
}

```

But when i try to execute search it re turns 0 results

```
POST tst/_search
{
  
  "query": {
    
      "query_string": {
        "default_field": "products.qty", 
        "query": "piece"
      }
  }
  
}

```

But below query returns 1 result (as expected)

```
POST tst/_search
{
  
  "query": {
    
      "query_string": {
        "default_field": "products.qty", 
        "query": "pcs"
      }
  }
  
}

```

could you please help to understand how synonyms work and if anything i am missing for configuring the synonyms.

Thank you for your help.

Thank you,  
Aditya

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 16, 2020, 6:03pm UTC](https://discuss.elastic.co/t/synonyms-not-getting-applied/215366/2 "2020-01-16T18:03:27Z")

</div>

You defined an analyzer but did not apply it to your field as you did not define a mapping.

---

<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:** [February 13, 2020, 6:06pm UTC](https://discuss.elastic.co/t/synonyms-not-getting-applied/215366/3 "2020-02-13T18:06:17Z")

</div>

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