betto86
betto86

Reputation: 714

Fewer than Expected Results from Elasticsearch's Fuzzy Query

I'm having some strange behaviour with elasticsearch fuzzy query, and I don't know what I'm doing wrong.

These are names inside my index:

  "hits": [
     {
           "name": "bbbb"

           "name": "abab"

           "name": "abbb"

           "name": "aaaa"
        }
     }
  ]

But this query, which suppose to return all the four elements, returns me only "abab" and "aaaa".

POST /test/_search?pretty
{
   "size": 10,
   "query": {
      "fuzzy": {
         "name": {
            "value": "aaaa",
            "fuzziness": 4
         }
      }
   }
}

Name field is mapped as string type. As a side question, does setting not_analyzed mapping to the field affects the fuzzy query results?

Upvotes: 2

Views: 162

Answers (1)

eemp
eemp

Reputation: 1166

Based on Elasticsearch's Common Options - Fuzziness documentation referenced at the end of Fuzzy Query documentation, for string fields, the fuzziness parameter only seems to take one of the following values: 0, 1, 2, AUTO, 0.0...0.1. The last piece in that section as notes:

Note: in all APIs except for the Fuzzy Like This Query, the maximum allowed edit distance is 2.

Anything besides this, as you observed, seems to get capped off at an edit distance of 2. This is all for later versions of Elasticsearch since documentation for 0.90 is a bit different.

Upvotes: 3

Related Questions