fuzzy searching with query_string Elasticsearch

霸气de小男生 提交于 2020-01-03 15:24:09

问题


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


回答1:


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

{
  "query": {
    "query_string": {
      "query": "class~"
    }
  }
}


来源:https://stackoverflow.com/questions/33225204/fuzzy-searching-with-query-string-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!