Fuzzy query don't working as expected

Hello!
Recently I started studying elasticsearch(8.6.1) and got a very incomprehensible behavior.
My index:

PUT items2/_settings
{
  "settings": {
    "analysis": {
      "filter": {
        "ru_stop": {
          "type": "stop",
          "stopwords": "_russian_"
        },
        "ru_stemmer": {
          "type": "stemmer",
          "language": "russian"
        },
        "first_synonyms": {
            "type": "synonym",
            "synonyms": ["яицо, яйцо", "курица, куриное"]
          }
      },
      "analyzer": {
        "default": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "ru_stop",
            "ru_stemmer",
            "first_synonyms"
          ],
          "char_filter": ["html_strip"]
        }
      },
      "mappings": {
        "properties": {
          "description": {
            "type": "text",
            "analyzer": "default"
          }
        }
      }
    }
  }
}

I add some test doc:

PUT /items2/_doc/14
{
    "description" :  "Крылья"
}

This fuzzy query doesn't work:

GET /items2/_search
{
  "query": {
    "fuzzy": {
      "description": {
        "value": "Крылья",
        "fuzziness": "2",
        "max_expansions": 5,
        "prefix_length": 0,
        "transpositions": true
      }
    }
  }
}

But this match query with fuzziness is working:

GET /items2/_search
{
  "query": {
    "match": {
      "description": {
        "query": "Крылья",
        "fuzziness": "2",
        "max_expansions": 5,
        "prefix_length": 0
      }
    }
  }
}

What's wrong with my fuzzy query? Thank you.

Hi @pavel4008

Fuzzy query is part of the Term Level Queries

Unlike full-text queries, term-level queries do not analyze search terms. Instead, term-level queries match the exact terms stored in a field.

So, with fuzzy query your term is not analyzed by the "default" analyzer. So to occur the correspondence you would have to inform "крыл" or search in the keyword field, eg "description.keyword".

1 Like

Thank you. In official guide I missed this difference

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.