问题
I am trying to design a query in which, I can use wildcard and Fuzzy query together.
According to me, query_string is used for wildcard searches and multi_match can be used for fuzziness.
I want a query which will search on words :-
"elast" : - provide results elastic and elasticsearch. "elasttc" :- also provide results as elastic and elasticsearch.
Elastic search supports wildcard and fuzzy query together??
Thanks in advance...
回答1:
{
"query": {
"bool": {
"should": [
{
"match": {
"title": "testing"
}
},
{
"wildcard": {
"title": "*testing*"
}
},
{
"fuzzy": {
"title": "testing"
}
}
],
"minimum_should_match": 1
}
}
}
回答2:
You can use it with Query String with wildcards. The suffix ~AUTO*
enables a prefix query with fuzzy, also you can use the fields selection like multi_match
query:
{
"query": {
"query_string" : {
"fields" : ["name^2", "content^1"],
"query" : "elasttc~AUTO*"
}
}
}
You can change the AUTO
keyword with a numeric value too, as the same fuzziness
parameter.
来源:https://stackoverflow.com/questions/52344191/wildcard-and-fuzzy-query-together-in-elastic-search