# Weired behaviour of fuzziness in elasticsearch

**URL:** https://discuss.elastic.co/t/weired-behaviour-of-fuzziness-in-elasticsearch/326058
**Category:** Elasticsearch
**Created:** [February 21, 2023, 11:14am UTC](https://discuss.elastic.co/t/weired-behaviour-of-fuzziness-in-elasticsearch/326058 "2023-02-21T11:14:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![alliswell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alliswell/32/117514_2.png) [@alliswell](https://discuss.elastic.co/u/alliswell)
#### Post date: [February 21, 2023, 11:14am UTC](https://discuss.elastic.co/t/weired-behaviour-of-fuzziness-in-elasticsearch/326058/1 "2023-02-21T11:14:48Z")

</div>

I have following document in my\_index:

```auto
{
  "title": "weiß",
  "id": 1
}

```

Consider the following query:

```auto
GET my_index/_search?explain=true
{
  "_source": ["title"], 
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "title": {
              "query": <query>,
              "fuzziness": "AUTO"
            }
          }
        }
      ]
    }
  }
}

```

I can't figure out why query="weißee" matches the above document, but query="weißer" doesn't. Since both are at edit distance of 2, I would expect both to match. Even with if I set fuzziness to 3, 4,.. still `weißer` is not matching.

Here is mapping and analyzer setting of 'title' field in my\_index:

## Mapping:

```auto
"title" : {
  "type" : "text",
  "analyzer" : "my_analyzer"
},

```

## Setting:

```auto
"my_analyzer" : {
  "filter" : [
    "lowercase",
    "asciifolding"
  ],
  "type" : "custom",
  "tokenizer" : "standard"
}

```

Output of analyzer on title field

 ![21-45-hbop1-ib7zm](https://us1.discourse-cdn.com/elastic/original/3X/2/8/28b1236deeb7df2bc2efbc42904471c1b509adbe.png)

---

<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 21, 2023, 12:23pm UTC](https://discuss.elastic.co/t/weired-behaviour-of-fuzziness-in-elasticsearch/326058/2 "2023-02-21T12:23:46Z")

</div>

Hi @alliswell

I cant reproduce the problem with your informations. Look my tests:

Mapping:

```auto
PUT my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "filter": [
            "lowercase",
            "asciifolding"
          ],
          "type": "custom",
          "tokenizer": "standard"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text",
        "analyzer": "my_analyzer"
      }
    }
  }
}

```

Document:

```auto
POST my_index/_doc
{
  "title":"weiß"
}

```

Query  
I get result when search by weißer.

```auto
GET my_index/_search
{
  "_source": ["title"], 
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "title": {
              "query": "weißer",
              "fuzziness": "AUTO"
            }
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![alliswell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alliswell/32/117514_2.png) [@alliswell](https://discuss.elastic.co/u/alliswell)
#### Post date: [February 22, 2023, 9:10am UTC](https://discuss.elastic.co/t/weired-behaviour-of-fuzziness-in-elasticsearch/326058/3 "2023-02-22T09:10:14Z")

</div>

Thanks for the reply, @andre.coelho, we were able to resolve this. In my post I only shared one sample doc, but our actual index contains large number of documents. During fuzzy matching, by default Elasticsearch set "max\_expansions" to 50, which limits number of fuzzy combination ES will try before halting search. Due to this sometime is possible that ES will not able eb able to retrieve releavnt documents.

ref:

> <https://stackoverflow.com/questions/50033895/elasticsearch-fuzzy-query-max-expansions>

---

<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 22, 2023, 9:10am UTC](https://discuss.elastic.co/t/weired-behaviour-of-fuzziness-in-elasticsearch/326058/4 "2023-03-22T09:10:41Z")

</div>

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