问题
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