Hamed M
Hamed M

Reputation: 329

How to search for similar words?

I am a newbie in Elasticsearch so i distributed like this:

Elastic version(6.3.1)

PUT my_index/_doc/1
{
  "game_name": "clash of clans"
}

GET my_index/_search
{
   "query" : {
     "match_phrase_prefix" : {
       "game_name" : "clash"
    }
  }
}

This is ok, but I want below code :

  GET my_index/_search
    {
       "query" : {
         "match_phrase_prefix" : {
           "game_name" : "lash"

//--OR
           "game_name : "klash"

//--OR

           "game_name : "clsh"
        }
      }
    }

That has none result, Could you please point me how to resolve this problem?

Thanks and regards!

Upvotes: 2

Views: 1732

Answers (1)

Adam T
Adam T

Reputation: 1691

Use a fuzzy search

GET /_search
{
    "query": {
       "fuzzy" : { "game_name" : "klash" }
    }
}

Upvotes: 5

Related Questions