Fuzzy query

Fuzzy query #

Returns documents that contain terms similar to the search term, within the maximum edit distance (Levenshtein — with transpositions counting as a single edit by default).

Inside a nested query: not supported yet — the clause is rejected with an HTTP 400 naming the offending clause.

Examples #

"AUTO" picks the budget from the value’s length — serch is 5 characters, so AUTO grants a single edit, which is exactly the insertion needed to reach search:

POST /my-collection/_search
{
  "query": {
    "fuzzy": {
      "field": "user.id",
      "value": "kiiby",
      "fuzziness": 2
    }
  }
}

Parameters for fuzzy #

  • <field>
    (Required, string) Field you wish to search.
  • value
    (Required, string) Term you wish to find in the provided <field>.
  • fuzziness
    (Optional) Maximum edit distance allowed for matching: an integer 0–2, "AUTO", or "AUTO:low,high". "AUTO" picks the budget from the value’s length at query time — shorter than low characters (default 3): 0 edits; shorter than high characters (default 6): 1 edit; otherwise 2. Values above 2 clamp to 2 (Levenshtein automata are only implemented up to distance 2). Default 0 (exact) — note Elasticsearch defaults this parameter to AUTO, so ES users must write "AUTO" explicitly to keep ES’s behavior.
  • prefix_length
    (Optional, integer, default: 0) The first N characters of every expansion term must match the query value exactly.
  • max_expansions
    (Optional, integer, default: 50) Cap on the number of expansion terms considered, best-distance-first.
  • transpositions
    (Optional, boolean, default: true) An adjacent-character transposition (ab → ba) counts as one edit. false re-checks each candidate with strict Levenshtein distance.
  • case_insensitive
    (Optional, boolean, default: false) Fold case on both the query value and candidate terms before matching.
  • boost
    (Optional, float, default: 1.0) Decrease or increase the relevance scores of the query.
Calendar September 30, 2026
Edit Edit this page