# Default analyzers in elastic search

**URL:** <https://discuss.elastic.co/t/default-analyzers-in-elastic-search/39774>\
**Category:** Elasticsearch\
**Created:** [January 21, 2016, 1:49pm UTC](https://discuss.elastic.co/t/default-analyzers-in-elastic-search/39774 "2016-01-21T13:49:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinivas](https://avatars.discourse-cdn.com/v4/letter/s/ecccb3/32.png) [@srinivas](https://discuss.elastic.co/u/srinivas)\
**Post date:** [January 21, 2016, 1:49pm UTC](https://discuss.elastic.co/t/default-analyzers-in-elastic-search/39774/1 "2016-01-21T13:49:10Z")

</div>

I have added the following in my yml file.  
index :  
analysis :  
analyzer :  
default :  
tokenizer : keyword

But when I am seeing my index metadata at head plugin I am not able to find these index\_analyzer and search\_analyzer in 2.1.1. I was able to see these two fileds in metadata in the previous version of ES 1.1.1 index.

I am not sure if these analyzers are getting applied on the index while indexing and searching? Is there anyway we can test the custom analyzers created on index??

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [January 26, 2016, 7:56am UTC](https://discuss.elastic.co/t/default-analyzers-in-elastic-search/39774/2 "2016-01-26T07:56:14Z")

</div>

Hi Srinivas,

while it may be possible to specify these settings in the yml file we advise you to [define it in the index settings](https://www.elastic.co/guide/en/elasticsearch/guide/master/_controlling_analysis.html#_configuring_analyzers_in_practice).

Suppose you have an index, called `sample_index`. Then you can create an analyzer with the `keyword` tokenizer as follows:

```auto
PUT /sample_index
{
   "settings": {
      "analysis": {
         "analyzer": {
            "default": {
               "tokenizer": "keyword"
            }
         }
      }
   }
}

```

You can test analyzers with the [analyze API](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/indices-analyze.html). Here I analyze the string "This is a test" with the default analyzer for all indices (the "+" sign is just the URL encoding of a space character which is needed because I specify the text as a URL parameter):

```auto
GET /_analyze?text=This+is+a+test

```

which produces:

```auto
{
   "tokens": [
      {
         "token": "this",
         "start_offset": 0,
         "end_offset": 4,
         "type": "<ALPHANUM>",
         "position": 0
      },
      {
         "token": "is",
         "start_offset": 5,
         "end_offset": 7,
         "type": "<ALPHANUM>",
         "position": 1
      },
      {
         "token": "a",
         "start_offset": 8,
         "end_offset": 9,
         "type": "<ALPHANUM>",
         "position": 2
      },
      {
         "token": "test",
         "start_offset": 10,
         "end_offset": 14,
         "type": "<ALPHANUM>",
         "position": 3
      }
   ]
}

```

You can clearly see that the tokens are split on whitespace characters.

If you analyze this text on the `sample_index` (note that the added index name as first part of the path!):

```auto
GET /sample_index/_analyze?text=This+is+a+test

```

it produces:

```auto
{
   "tokens": [
      {
         "token": "This is a test",
         "start_offset": 0,
         "end_offset": 14,
         "type": "word",
         "position": 0
      }
   ]
}

```

which is due to the keyword tokenizer that I have defined on that index.

So, in summary, don't specify the analyzer in the yml file (reasons: see link at the top) but put it in the index settings. If you create lots of indices, then you can always use [index templates](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/indices-templates.html)

Daniel

---

<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:** [July 5, 2017, 11:21pm UTC](https://discuss.elastic.co/t/default-analyzers-in-elastic-search/39774/3 "2017-07-05T23:21:42Z")

</div>


