# Custom analyzer for search and indexing

**URL:** <https://discuss.elastic.co/t/custom-analyzer-for-search-and-indexing/348661>\
**Category:** Elasticsearch\
**Created:** [December 5, 2023, 4:04pm UTC](https://discuss.elastic.co/t/custom-analyzer-for-search-and-indexing/348661 "2023-12-05T16:04:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssanja](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ssanja/32/122573_2.png) [@ssanja](https://discuss.elastic.co/u/ssanja)\
**Post date:** [December 5, 2023, 4:04pm UTC](https://discuss.elastic.co/t/custom-analyzer-for-search-and-indexing/348661/1 "2023-12-05T16:04:57Z")

</div>

Hello, when creating an index I specifically created a custom analyzer which should be used for indexing and searching (see the example code below)

```auto
  "settings": {
     "analysis": {
      "analyzer": {
        "custom_name_analyzer": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": [
            "lowercase",
            "asciifolding",
            "word_delimiter"
          ]
        }
      }
    }
  }

```

It is used for a name field in a document like this:

```auto
  "mappings": {
    "dynamic": "false",
    "properties": {
      "name": {
        "properties": {
          "cs": { "type": "text",
                  "analyzer": "custom_name_analyzer",
                  "search_analyzer": "custom_name_analyzer"
          }
        }
      }

```

However, when I do `GET <index-name>/_mapping`, I do not see the `search_analyzer` being provided.  
What is the reason for it?  
How can I determine which analyzer is used for searching in this case?

---

<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:** [December 6, 2023, 6:33am UTC](https://discuss.elastic.co/t/custom-analyzer-for-search-and-indexing/348661/2 "2023-12-06T06:33:34Z")

</div>

If you just specify an `analyzer`, this will be used for both indexing and search. In your case you therefore do not need to specify the `search_analyzer` as it is not different from the `analyzer`. If you in the mapping see the `analyzer` correctly set and no `search_analyzer` specified, I suspect it is possible Elasticsearch has rationalised this as they are the same and that would be the standard way of configuring it.

---

<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:** [January 3, 2024, 6:34am UTC](https://discuss.elastic.co/t/custom-analyzer-for-search-and-indexing/348661/3 "2024-01-03T06:34:06Z")

</div>

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