# Query full senetnce with synonyms

**URL:** <https://discuss.elastic.co/t/query-full-senetnce-with-synonyms/140729>\
**Category:** Elasticsearch\
**Created:** [July 19, 2018, 12:50pm UTC](https://discuss.elastic.co/t/query-full-senetnce-with-synonyms/140729 "2018-07-19T12:50:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruti](https://avatars.discourse-cdn.com/v4/letter/r/e19adc/32.png) [@ruti](https://discuss.elastic.co/u/ruti)\
**Post date:** [July 19, 2018, 12:50pm UTC](https://discuss.elastic.co/t/query-full-senetnce-with-synonyms/140729/1 "2018-07-19T12:50:04Z")

</div>

Hi everybody.

I'm new here, learning the elasticsearch.  
I want to be able to find a full sentence like "live usa" while "usa" is an synonyms of (usa,united states,u s a,united states of america"

if I search for only "usa" or "u s a" etc. It's found all the occurances, but if I search for "live usa" it;s found nothing.

// below my code.

```
PUT /my_index
{
  "settings": {
    "analysis": {
      "filter": {
        "my_synonym_filter": {
          "type": "synonym",
          "synonyms": [
            "usa,united states,u s a,united states of america"
          ]
        }
      },
      "analyzer": {
        "my_synonyms": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "my_synonym_filter"
          ]
        }
      }
    }
  },
   "mappings": {
    "table1": { 
      "properties": { 
        "text": { "type": "text" ,"analyzer": "my_synonyms" }
      }
    }
  }
}

POST /my_index/table1/_bulk
{ "index": { "_id":1}}
{"text":"I live in the usa"}
{ "index": { "_id":2}}
{"text":"the united states of america are pluralzse"}
{ "index": { "_id":3}}
{"text":"I want to visit canade"}
{ "index": { "_id":4}}
{"text":"can you go to the u s a?"}

GET /my_index/table1/_search
{
  "query": {
    "match_phrase": {
      "text": {
        "query": "usa",
        "analyzer": "my_synonyms"
      }
    }
  }
}

```

thanks in advance!  
Ruti

---

<div class="post-metadata">

**Author:** ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)\
**Post date:** [July 27, 2018, 5:05pm UTC](https://discuss.elastic.co/t/query-full-senetnce-with-synonyms/140729/2 "2018-07-27T17:05:21Z")

</div>

I suspect your problem with finding a phrase "live usa" is not because of synonyms. It is because there is no such a phrase in your documents. Try to search for the phrase "live in the usa" and see if you can find any documents.

---

<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:** [August 24, 2018, 5:05pm UTC](https://discuss.elastic.co/t/query-full-senetnce-with-synonyms/140729/3 "2018-08-24T17:05:24Z")

</div>

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