# Elasticsearch Not\_analyzed and analyzed

**URL:** <https://discuss.elastic.co/t/elasticsearch-not-analyzed-and-analyzed/40465>\
**Category:** Elasticsearch\
**Created:** [January 29, 2016, 10:29am UTC](https://discuss.elastic.co/t/elasticsearch-not-analyzed-and-analyzed/40465 "2016-01-29T10:29:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![userguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/userguy/32/6224_2.png) [@userguy](https://discuss.elastic.co/u/userguy)\
**Post date:** [January 29, 2016, 10:29am UTC](https://discuss.elastic.co/t/elasticsearch-not-analyzed-and-analyzed/40465/1 "2016-01-29T10:29:31Z")

</div>

Hello For certain requirement i have made all the index not\_analyzed

{  
"template": "\*",  
"mappings": {  
"_default_": {  
"dynamic\_templates": [  
{  
"my\_template": {  
"match\_mapping\_type": "string",  
"mapping": {  
"index": "not\_analyzed"  
}  
}  
}  
]  
}  
}  
}  
But now as per our requirement i have to make certain field as analyzed . and keep rest of the field as not analyzed

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [January 29, 2016, 6:07pm UTC](https://discuss.elastic.co/t/elasticsearch-not-analyzed-and-analyzed/40465/2 "2016-01-29T18:07:50Z")

</div>

If you explicitly change a specific field's configuration in the mapping,  
it will override any settings you defined in the template. Keep your  
mapping as is, and simply add the field in your mapping as analyzed.

---

<div class="post-metadata">

**Author:** ![userguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/userguy/32/6224_2.png) [@userguy](https://discuss.elastic.co/u/userguy)\
**Post date:** [January 30, 2016, 3:15am UTC](https://discuss.elastic.co/t/elasticsearch-not-analyzed-and-analyzed/40465/3 "2016-01-30T03:15:03Z")

</div>

Ok .. I am new to elasticsearch and understanding how mapping and templates work .. But for my case i have made everything as not\_analyzed but now for one of the field i have to make it as analyzed and also at same time not\_analyzed .. Now as per your suggestion can i do without changing the current template . How can i do it???? It would be of great help if you can you help me with a example .

---

<div class="post-metadata">

**Author:** ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)\
**Post date:** [January 30, 2016, 6:08am UTC](https://discuss.elastic.co/t/elasticsearch-not-analyzed-and-analyzed/40465/4 "2016-01-30T06:08:10Z")

</div>

I think there is no option to change mapping for a few fields. You just need to overwrite the current mapping template with a new one having the fields you need changed to **analyzed**. But changing this only affect new indexes/documents, so I think what you need to do is to

1. Change your index template
2. Reindex your data

---

<div class="post-metadata">

**Author:** ![userguy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/userguy/32/6224_2.png) [@userguy](https://discuss.elastic.co/u/userguy)\
**Post date:** [January 30, 2016, 7:12am UTC](https://discuss.elastic.co/t/elasticsearch-not-analyzed-and-analyzed/40465/5 "2016-01-30T07:12:34Z")

</div>

One more thing to add if i rewrite my template , I have nested fields too , I get error for nested data in document .. Now in this case i need mapping where all i want few fields as not\_analyzed and analyzed at same time while rest of the field should be not\_analyzed . I am facing this issue because of type of data i am having where the new fields could be added from application at any time so the data we need for new field should be not\_analyzed whereas to make search case insensitive i want to keep both as analyzed and not analyzed for few fields . I hope this gives some insight about the dilemma i am facing

---

<div class="post-metadata">

**Author:** ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)\
**Post date:** [January 30, 2016, 8:35am UTC](https://discuss.elastic.co/t/elasticsearch-not-analyzed-and-analyzed/40465/6 "2016-01-30T08:35:57Z")

</div>

It looks like you need to combine dynamic mappings to set all string fields to not\_analyzing (for all newly created fields) and mappings for those fields need to be analyzed. Please look at part of my netflow template

```
PUT _template/netflow
{
  "template": "netflow*",
  "settings": {
    "index.refresh_interval": "5s"
  },
  "mappings": {
    "_default_": {
      "_all": {
        "enabled": true,
        "omit_norms": true
      },
      "dynamic_templates": [
        {
          "message_field": {
            "match": "message",
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "index": "analyzed",
              "omit_norms": true
            }
          }
        },
        {
          "string_fields": {
            "match": "*",
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "index": "not_analyzed",
              "omit_norms": true
            }
          }
        }
      ],
      "properties": {
        "@version": {
          "type": "string",
          "index": "not_analyzed"
        },
        "host": {
          "type": "ip"
        },
        "IPV4_SRC_ADDR": {
          "type": "ip"
        },
        "IPV4_DST_ADDR": {
          "type": "ip"
        },
        "IN_SRC_MAC": {
          "type": "string",
          "index": "not_analyzed"
        },
        "your_analyzed_fields_go_here": {
          "type": "string",
          "index": "analyzed"

```

Inside "properties": { } is where you put all the analyzed fields. Fields that are not in here will use the dynamic mapping.

---

<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:20pm UTC](https://discuss.elastic.co/t/elasticsearch-not-analyzed-and-analyzed/40465/7 "2017-07-05T23:20:11Z")

</div>


