# Set default to not\_analyzed

**URL:** <https://discuss.elastic.co/t/set-default-to-not-analyzed/60911>\
**Category:** Elasticsearch\
**Created:** [September 19, 2016, 3:33pm UTC](https://discuss.elastic.co/t/set-default-to-not-analyzed/60911 "2016-09-19T15:33:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![arsenepark](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@arsenepark](https://discuss.elastic.co/u/arsenepark)\
**Post date:** [September 19, 2016, 3:33pm UTC](https://discuss.elastic.co/t/set-default-to-not-analyzed/60911/1 "2016-09-19T15:33:40Z")

</div>

hi, there,

I know ES default setting is "analyzed", how to set it to "not\_analyzed", 'cause I want to try term-search with most of my fields.

Thanks,  
Dennis

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [September 19, 2016, 4:25pm UTC](https://discuss.elastic.co/t/set-default-to-not-analyzed/60911/2 "2016-09-19T16:25:09Z")

</div>

You can define an [index template](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/indices-templates.html) with a [dynamic template](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/dynamic-templates.html) which sets that to `not_analyzed`.

---

<div class="post-metadata">

**Author:** ![arsenepark](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@arsenepark](https://discuss.elastic.co/u/arsenepark)\
**Post date:** [September 21, 2016, 8:58am UTC](https://discuss.elastic.co/t/set-default-to-not-analyzed/60911/3 "2016-09-21T08:58:00Z")

</div>

Thanks, David

I tried with your guide, but ES is working really strange.

I tied the following template, and assuming any string value in any type in i2 index, is not\_analized, but it's not (some are not\_analized while some are analized)  
What I want is: any new string-value field in any type in i2 index, is not\_analized.

```
curl -XPUT 'localhost:8200/i2?pretty' -d'
{
  "mappings": {
    "t2": {
      "dynamic_templates": [
        {
          "strings": {
            "match_mapping_type": "string",
            "mapping": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        }
      ]
    }
  }
}'

curl -X GET "localhost:8200/i2/_mapping?pretty"

curl -X PUT "http://localhost:8200/i2/t2/1?pretty" -d '{"first_name":"John","age":25,"interests":[{"name":"sports","level":"A"},{"name":"music","level":"B"}]}'
curl -X PUT "http://localhost:8200/i2/form1/2?pretty" -d '{"first_name":"Jim","age":28,"interests":[{"name":"water","level":"A"},{"name":"dive","level":"B"}]}'
curl -X PUT "http://localhost:8200/i2/t2/3?pretty" -d '{"a":"xyz"}'
curl -X PUT "http://localhost:8200/i2/form1/3?pretty" -d '{"a":"xyz"}'
curl -X PUT "http://localhost:8200/i2/form1/3?pretty" -d '{"p1":"xyz"}'
curl -X POST "http://localhost:8200/i2/t2/?pretty" -d '{"ccc":"xyz"}'
curl -X POST "http://localhost:8200/i2/t2/?pretty" -d '{"dddd":"xyz"}'
curl -X PUT "http://localhost:8200/i2/t2/100?pretty" -d '{"f2":"xyz"}'

curl -X PUT "http://localhost:8200/i2/form1/3?pretty" -d '{"a":"xyz"}'
curl -X PUT "http://localhost:8200/i2/t2/100?pretty" -d '{"ccc":"xyz"}'
curl -X PUT "http://localhost:8200/i2/t2/100?pretty" -d '{"xyz":"xyz"}'

curl -X POST "http://localhost:8200/i2/form1/?pretty" -d '{"q1":"123"}'
curl -X POST "http://localhost:8200/i2/ttt3/?pretty" -d '{"first_name":"123"}'

work@dev01.dev01:~/softwares/elasticsearch-2.3.5/ curl -X GET "localhost:8200/i2/_mapping?pretty"
{
  "i2" : {
    "mappings" : {
      "ttt3" : {
        "properties" : {
          "first_name" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "qwer" : {
            "type" : "string"
          }
        }
      },
      "t2" : {
        "dynamic_templates" : [ {
          "strings" : {
            "mapping" : {
              "index" : "not_analyzed",
              "type" : "string"
            },
            "match_mapping_type" : "string"
          }
        } ],
        "properties" : {
          "a" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "age" : {
            "type" : "long"
          },
          "ccc" : {
            "type" : "string"
          },
          "dddd" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "e1" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "f2" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "first_name" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "interests" : {
            "properties" : {
              "level" : {
                "type" : "string",
                "index" : "not_analyzed"
              },
              "name" : {
                "type" : "string",
                "index" : "not_analyzed"
              }
            }
          },
          "xyz" : {
            "type" : "string",
            "index" : "not_analyzed"
          }
        }
      },
      "form1" : {
        "properties" : {
          "a" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "age" : {
            "type" : "long"
          },
          "ccc" : {
            "type" : "string"
          },
          "first_name" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "interests" : {
            "properties" : {
              "level" : {
                "type" : "string",
                "index" : "not_analyzed"
              },
              "name" : {
                "type" : "string",
                "index" : "not_analyzed"
              }
            }
          },
          "p1" : {
            "type" : "string"
          },
          "q1" : {
            "type" : "string"
          }
        }
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![arsenepark](https://avatars.discourse-cdn.com/v4/letter/a/d07c76/32.png) [@arsenepark](https://discuss.elastic.co/u/arsenepark)\
**Post date:** [September 21, 2016, 11:03am UTC](https://discuss.elastic.co/t/set-default-to-not-analyzed/60911/4 "2016-09-21T11:03:58Z")

</div>

The answer is [_default_ mapping](https://www.elastic.co/guide/en/elasticsearch/reference/2.4/default-mapping.html)  
🙂

Dinnis

---

<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, 10:18pm UTC](https://discuss.elastic.co/t/set-default-to-not-analyzed/60911/5 "2017-07-05T22:18:34Z")

</div>


