Global Search

Hello Everyone,

I would like to perform a global search by providing a keyword like below (2 different requests) in the request. It returns the result which matches the word "pizza" in any of the field. But if I give "piz" in the request then it is not returning anything. Ultimately it expects complete word instead partial word. If I want to use any search string like "piz", may I know what do I need to do? Because when user performs global search then we can't expect exact word which matches. Please share your thoughts on this.

GET /_search
{
"query": {
"multi_match" : {
"query" : "pizza",
"fields" :
}
}
}

GET /_search
{
"query": {
"simple_query_string" : {
"query": "Dominos"
}
}
}

There are several ways to tackle this problem. You have to take balance between recall and precision. fuzziness option is a good start point. You can use fuzziness also in multi_match queries and query-string queries. If you want exact partial match, you can use n-gram analyzer or wildcard query with wildcard field.

Can you please share some examples if possible. That will be great. Because Fuzziness link which you have shared is not helping for my scenario, it seems it mentioned the field name called "message". But in my case, I do not want to mention the specific field name. It is completely global within index.

You can use fuzziness with multi_match query as I said.

Yes, I used fuzziness like below. If I give "pizza" or "pizz" is working fine, but if I give"pi" then it is not returning any results. Fuzziness working partially.

GET /_search
{
"query": {
"multi_match" : {
"query" : "pizz",
"fuzziness": "AUTO",
"fields" :
}
}
}

Yes, that is what i said the balance between recall and precision. 'AUTO' allows one edit for 5 letter term. if you set "fusiness": 2, "piz" will match but "pi" will not. The advantage of fuzziness query is that can match something like "piza" or "pissa".

Again, another way is to use n-gram analyzer or wildcard query with wildcard field.

Thank you. Wild card works.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.