Fuzziness lets Elasticsearch match indexed terms that resemble a query term, helping searches recover from misspellings instead of returning no results. section 2.3.8 section 9.9
Recovering a misspelled movie search
A search for "rama" with fuzziness 1 can match "drama" because one character change is allowed. Similarly, "cake" can match "take", "bake", "lake", and "make". Increasing fuzziness to 2 handles examples such as "ama" when two characters are missing. 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 to search the books index for the misspelled tag "Komputer" while permitting one character edit. section 2.3.8
Choose the setting according to the expected spelling variation:
- Set fuzziness to 0, 1, or 2 to allow zero, one, or two character insertions, deletions, or modifications. section 10.5.6
- Use AUTO when the likely number of mistakes is unknown; it selects the edit distance from word length. section 9.9
- Remember that fuzzy queries use similarity rather than wildcard operators, and term-level searches produce matching or no-match results. section 9.10 section 9.9
