# Fuziness not working when querying in larger index

**URL:** https://discuss.elastic.co/t/fuziness-not-working-when-querying-in-larger-index/350503
**Category:** Elasticsearch
**Created:** [January 6, 2024, 7:44am UTC](https://discuss.elastic.co/t/fuziness-not-working-when-querying-in-larger-index/350503 "2024-01-06T07:44:17Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![SriramOnGrid](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SriramOnGrid](https://discuss.elastic.co/u/SriramOnGrid)
#### Post date: [January 6, 2024, 7:44am UTC](https://discuss.elastic.co/t/fuziness-not-working-when-querying-in-larger-index/350503/1 "2024-01-06T07:44:17Z")

</div>

Hi team, I wanted to fuziness for the purpose of finding the words with minor spelling mistakes.

> The query I am using is

```auto
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "respondent_name.text":{
              "query": "Surender",
              "fuzziness": "2"
            }
          }
        },
        {
          "match": {
            "cnr":"WBCS020024922021"
          }
        }
      ]
    }
  }
}

```

> Where the document I wanted to find is:

```auto
{
  .....

  "cnr": "WBCS020024922021",        
  "respondent_name": [
    "SURENDRA @ SURENDRA "
  ],
  ....

}

```

> Mapping:

```auto
"cnr": {
    "type": "keyword"
   },
"respondent_name": {
  "type": "keyword",
  "fields": {
    "text": {
      "type": "text",
      "analyzer": "respondent_name_analyzer",
      "search_analyzer": "respondent_name_search_analyzer"
    },
    "phonetic": {
      "type": "text",
      "analyzer": "name_phonetics_analyzer",
      "search_analyzer": "name_phonetics_analyzer"
    }
  },
  "copy_to": [
    "global_content"
  ]
}

```

> Settings:

```auto
"respondent_name_analyzer": {
  "tokenizer": "standard",
  "filter": [
    "word_delimiter_graph",
    "lowercase",
    "respondent_name_edgegram_filter",
    "remove_duplicates"
  ]
},
"respondent_name_search_analyzer": {
  "tokenizer": "standard",
  "filter": [
    "word_delimiter_graph",
    "lowercase",
    "remove_duplicates"
  ]
}

```

Doing the same query in an index with 200 million documents, I am unable to fetch the document, but doing the query in an index with similar mapping and settings having less documents(\<1000) is providing the result.

Note: The document I wanted to query is available in both the indexes, also I have verified by querying only CNR and it gives the result in both.

In broader view: I wanted to get the results of Surendra while querying Surender, I am not interested to use edge\_gram or ngram as that gives more false positives.

One thing I noticed is if I query "Surendar" instead of "Surender" it's providing the result, I am totally confused why it's not providing the result when I am querying with Surender.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 6, 2024, 8:17am UTC](https://discuss.elastic.co/t/fuziness-not-working-when-querying-in-larger-index/350503/2 "2024-01-06T08:17:40Z")

</div>

> [@SriramOnGrid](#):
>
> ```auto
> "text": {
> "type": "text",
> "analyzer": "respondent_name_analyzer",
> "search_analyzer": "respondent_name_search_analyzer"
> },
> 
> ```

You are using different analysers at index and search time, which is a powerful feature but can also cause unintended issues. Please provide the full mappings and definition of the analysers so someone can try to reproduce the issue.

I would recommend using the [explain analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/indices-analyze.html#explain-analyze-api) to check how the `SURENDRA @ SURENDRA` string is analysed with the index time analyser specified in the mappings and then compare that to how the `Surender` string is analyzed by the search time analyzer.

> [@SriramOnGrid](#):
>
> In broader view: I wanted to get the results of Surendra while querying Surender, I am not interested to use edge\_gram or ngram as that gives more false positives.

The analyser you are using at index time seems to be using edge ngrams so I am not sure what you mean with this statement.

---

<div class="post-metadata">

### Author: ![SriramOnGrid](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SriramOnGrid](https://discuss.elastic.co/u/SriramOnGrid)
#### Post date: [January 6, 2024, 8:34am UTC](https://discuss.elastic.co/t/fuziness-not-working-when-querying-in-larger-index/350503/3 "2024-01-06T08:34:42Z")

</div>

Have provided the properties of the analysers that I am using in the mapping, please checkout 🙂

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 6, 2024, 9:08am UTC](https://discuss.elastic.co/t/fuziness-not-working-when-querying-in-larger-index/350503/4 "2024-01-06T09:08:25Z")

</div>

> [@SriramOnGrid](#):
>
> `respondent_name_edgegram_filter`

What is the definition of this filter? It does not look standard and I can not see it above. 🙂

---

<div class="post-metadata">

### Author: ![SriramOnGrid](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SriramOnGrid](https://discuss.elastic.co/u/SriramOnGrid)
#### Post date: [January 6, 2024, 9:24am UTC](https://discuss.elastic.co/t/fuziness-not-working-when-querying-in-larger-index/350503/5 "2024-01-06T09:24:10Z")

</div>

my bad:

```auto
"respondent_name_edgegram_filter": {
              "type": "edge_ngram",
              "min_gram": 3,
              "max_gram": 50,
              "preserve_original": true
            }

```

---

<div class="post-metadata">

### Author: ![SriramOnGrid](https://avatars.discourse-cdn.com/v4/letter/s/97f17d/32.png) [@SriramOnGrid](https://discuss.elastic.co/u/SriramOnGrid)
#### Post date: [January 10, 2024, 8:49am UTC](https://discuss.elastic.co/t/fuziness-not-working-when-querying-in-larger-index/350503/6 "2024-01-10T08:49:44Z")

</div>

Hi is there any update on this ?

---

<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: [February 7, 2024, 8:49am UTC](https://discuss.elastic.co/t/fuziness-not-working-when-querying-in-larger-index/350503/7 "2024-02-07T08:49:46Z")

</div>

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