liveBook · Manning

Fuzziness

As explained in Elasticsearch in Action, Second Edition

Fuzziness is a search setting that controls the permitted edit distance between a query term and matching indexed terms.

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

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains Levenshtein distance, numeric limits, AUTO behavior, and examples, but does not cover broader tuning.
Examples
Demonstrates misspelled computer, movie, cake, and Java-book searches with numeric and AUTO-style correction.
What it assumes
Assumes familiarity with Elasticsearch search requests and indexed fields while explaining edit distance from basic examples.
What you can do after
Apply fuzziness through Elasticsearch match or fuzzy queries to recover results from character-level spelling errors.
How it connects
Connects fuzzy queries with match queries, Levenshtein distance, wildcard queries, and term-level search.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.