# Fuzzy query don't working as expected

**URL:** <https://discuss.elastic.co/t/fuzzy-query-dont-working-as-expected/325070>\
**Category:** Elasticsearch\
**Created:** [February 8, 2023, 11:41pm UTC](https://discuss.elastic.co/t/fuzzy-query-dont-working-as-expected/325070 "2023-02-08T23:41:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pavel4008](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pavel4008/32/116993_2.png) [@pavel4008](https://discuss.elastic.co/u/pavel4008)\
**Post date:** [February 8, 2023, 11:41pm UTC](https://discuss.elastic.co/t/fuzzy-query-dont-working-as-expected/325070/1 "2023-02-08T23:41:35Z")

</div>

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

```auto
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:

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

```

This fuzzy query doesn't work:

```auto
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:

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

```

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

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [February 9, 2023, 1:23am UTC](https://discuss.elastic.co/t/fuzzy-query-dont-working-as-expected/325070/2 "2023-02-09T01:23:21Z")

</div>

Hi @pavel4008

Fuzzy query is part of the [Term Level Queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/term-level-queries.html)

> Unlike [full-text queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/full-text-queries.html), 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".

---

<div class="post-metadata">

**Author:** ![pavel4008](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pavel4008/32/116993_2.png) [@pavel4008](https://discuss.elastic.co/u/pavel4008)\
**Post date:** [February 9, 2023, 11:29am UTC](https://discuss.elastic.co/t/fuzzy-query-dont-working-as-expected/325070/3 "2023-02-09T11:29:08Z")

</div>

Thank you. In official guide I missed this difference

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 9, 2023, 11:29am UTC](https://discuss.elastic.co/t/fuzzy-query-dont-working-as-expected/325070/4 "2023-03-09T11:29:32Z")

</div>

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