10

i have a record saved in Elasticsearch which contains a string exactly equals to Clash of clans

now i want to search this string with Elasticsearch and i using this

{
    "query_string" : {
        "query" : "clash"
    }
}

its working perfectly but now if i write

"query" : "class"

it dont give me back any record so i realize i should use Fuzzy searching so i come to know that i can use fuzziness parameter with query_string so i did

{
    "query_string" : {
        "query" : "clas"
        "fuzziness":1
    }
}

but still elasticsearch is not returning anything! kindly help and i cant use Fuzzy query i just can use query_string. Thanks

maq
  • 1,175
  • 3
  • 17
  • 34

1 Answers1

24

You need to use the ~ operator to have fuzzy searching in query_string:

{
  "query": {
    "query_string": {
      "query": "class~"
    }
  }
}
Andrei Stefan
  • 51,654
  • 6
  • 98
  • 89