Query full senetnce with synonyms

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": [
   "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!

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.

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