# ES 7.12 - Different analyzers are getting used for indexing and searching

**URL:** <https://discuss.elastic.co/t/es-7-12-different-analyzers-are-getting-used-for-indexing-and-searching/272186>\
**Category:** Elasticsearch\
**Created:** [May 5, 2021, 1:03pm UTC](https://discuss.elastic.co/t/es-7-12-different-analyzers-are-getting-used-for-indexing-and-searching/272186 "2021-05-05T13:03:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![justramesh2000](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@justramesh2000](https://discuss.elastic.co/u/justramesh2000)\
**Post date:** [May 5, 2021, 1:03pm UTC](https://discuss.elastic.co/t/es-7-12-different-analyzers-are-getting-used-for-indexing-and-searching/272186/1 "2021-05-05T13:03:16Z")

</div>

Hello, I have an interesting issue to report for ES 7.12. For one of the dynamically indexed field the analyzer used for indexing is "ngram" but for searching its "standard". I am not sure if this is a bug or an intended change. This started happening since ES 7.10.

Below I am showing a simple mapping with one field and different analyzers. Below steps performed on 7.9 and 7.12 have different results. 7.9 gives a hit while 7.12 doesn't, reason being  
use of standard analyzer while searching.  
Steps to reproduce:

1. Create an Index with mapping.

```auto
     PUT - http://localhost:9200/{indexname}
    {

        "mappings": {

                "properties": {

                  "category": {

                        "properties": {

                            "id": {

                                "type": "long"

                            },

                            "name": {

                                "type": "keyword",

                                "normalizer": "lowercase_normalizer",

                                "fields": {

                                    "analyzed": {

                                        "type": "text",

                                        "analyzer": "content_asset_engram_analyzer"

                                    }

                                }

                            },

                            "parentId": {

                                "type": "long"

                            }

                        }

            }

            }

            },

            "settings": {

                "index": {

                    "max_ngram_diff": "3",

                    "refresh_interval": "30s",

                    "number_of_shards": "1",

                    "analysis": {

                        "normalizer": {

                            "lowercase_normalizer": {

                                "filter": ["lowercase"],

                                "type": "custom"

                            }

                        },

                        "analyzer": {

                            "default_search": {

                                "filter": ["lowercase"],

                                "type": "custom",

                                "tokenizer": "standard"

                            },

                            "content_asset_html_strip": {

                                "filter": ["lowercase"],

                                "type": "custom",

                                "char_filter": ["html_strip"],

                                "tokenizer": "content_asset_engram_tokenizer"

                            },

                            "content_asset_engram_analyzer": {

                                "filter": ["lowercase"],

                                "type": "custom",

                                "tokenizer": "content_asset_engram_tokenizer"

                            }

                        },

                        "tokenizer": {

                            "content_asset_engram_tokenizer": {

                                "token_chars": ["letter", "digit"],

                                "min_gram": "3",

                                "type": "ngram",

                                "max_gram": "6"

                            }

                        }

                    }

                }

            }
    }

```

1. Add document to the index

```auto
    POST http://localhost:9200/{indexname}/_doc
    {

        "category": {

                "id": 3962,

                "name": "Content Builder",
                "parentId": 0

            }
    }

```

1. Search

```auto
    GET http://localhost:9200/{indexname}/_search
    {

      "query": {

        "match": {

          "category.name.analyzed": "content"

        }

      }
    }

```

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 6, 2021, 12:53am UTC](https://discuss.elastic.co/t/es-7-12-different-analyzers-are-getting-used-for-indexing-and-searching/272186/2 "2021-05-06T00:53:18Z")

</div>

Welcome to our community! 😃 And thanks heaps for providing a replica here, it's super helpful!

I just ran this example on 7.9.3 and 7.12.1 and they both returned zero hits?

---

<div class="post-metadata">

**Author:** ![justramesh2000](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@justramesh2000](https://discuss.elastic.co/u/justramesh2000)\
**Post date:** [May 6, 2021, 1:41pm UTC](https://discuss.elastic.co/t/es-7-12-different-analyzers-are-getting-used-for-indexing-and-searching/272186/3 "2021-05-06T13:41:02Z")

</div>

thank you for your response.  
That is not my experience, I am getting a hit on 7.9.3. This is interesting though, should the search not return a hit on both versions? What does the response for explain api looks like

```auto
GET http://localhost:9200/{indexName}/_doc/{docId}/_explain 
{
    "query": {
        "match": {
            "category.name.analyzed": "content"
        }
    }
}

```

if that doesn't return anything, you could run explain on smaller words like "conten" and see if ngram analyzer was used during search.

---

<div class="post-metadata">

**Author:** ![justramesh2000](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@justramesh2000](https://discuss.elastic.co/u/justramesh2000)\
**Post date:** [May 11, 2021, 6:23pm UTC](https://discuss.elastic.co/t/es-7-12-different-analyzers-are-getting-used-for-indexing-and-searching/272186/4 "2021-05-11T18:23:25Z")

</div>

Mark Walkom, were you able to find out why search is not returning result for you in any of versions ? was explain api of any help ?

---

<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:** [June 8, 2021, 6:23pm UTC](https://discuss.elastic.co/t/es-7-12-different-analyzers-are-getting-used-for-indexing-and-searching/272186/5 "2021-06-08T18:23:43Z")

</div>

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