Skip to content

Fuzzy Query

Edit page

The Fuzzy Query generates matching terms that are within the maximum edit distance (2 by default) and then checks the term dictionary to find out which of those generated terms actually exist in the index. The query is not capped: it uses every matching term (the 50-term cap belongs to the partial query).

SEARCH /bank/
{
"_query": {
"favoriteFruit": {
"_fuzzy": "banna"
}
}
}

A similar effect could be obtained by using the tilde (“~”) character followed optionally by the edit distance as part of the query text:

SEARCH /bank/
{
"_query": {
"favoriteFruit": "banna~"
}
}

The following parameters are planned for the _fuzzy query (the only accepted form today is a string):

|--------------------------------------|-------------------------------------------------------| | _fuzziness | The maximum edit distance. Defaults to 2. | | _max_expansions | The maximum number of terms that the fuzzy query will expand to. No limit by default. | | _prefix_length | The number of initial characters which will not be “fuzzified”. This helps to reduce the number of terms which must be examined. Defaults to 0. |