Levenshtein distance measures the minimum number of single-character insertions, deletions, and substitutions needed to transform one string into another. In search, it lets Elasticsearch find likely matches despite spelling mistakes. section 10.10 section 2.3.8
A distance of 1 forgives one character change. Thus, a search for “rama” can find “drama,” while “ama” requires distance 2. Fuzziness can be set explicitly or left as AUTO, which chooses a distance from word length. section 9.9
Listing 2.14 Matching a phrase with a misspelling (using fuzziness)
GET books/_search
{
"query": {
"match": {
"tags": {
"query": "Komputer", #1
"fuzziness": 1 #2
}
}
}
}
Use a match query with fuzziness 1 to let a books search match the misspelled term “Komputer” with “Computer.” section 2.3.8
Fuzzy movie search
A fuzzy query for “rama” with fuzziness 1 can return drama movies. Unlike wildcard queries, fuzzy queries use edit distance rather than * or ? operators. section 9.9
Term-level fuzzy queries use Levenshtein distance. Full-text query_string fuzziness uses a default edit distance of 2 and may use Damerau–Levenshtein, which also supports adjacent-character transpositions. section 9.10 section 10.10





