# \[Solved\]Elasticsearch mapping {"dynamic" : "false"} not working?

**URL:** https://discuss.elastic.co/t/solved-elasticsearch-mapping-dynamic-false-not-working/60720
**Category:** Elasticsearch
**Created:** [September 16, 2016, 2:04pm UTC](https://discuss.elastic.co/t/solved-elasticsearch-mapping-dynamic-false-not-working/60720 "2016-09-16T14:04:27Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![abcfy2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abcfy2/32/453_2.png) [@abcfy2](https://discuss.elastic.co/u/abcfy2)
#### Post date: [September 16, 2016, 2:04pm UTC](https://discuss.elastic.co/t/solved-elasticsearch-mapping-dynamic-false-not-working/60720/1 "2016-09-16T14:04:27Z")

</div>

I don't want a field `date` to be indexed. So I disabled the `dynamic` property. Here is my mapping:

```json
curl localhost:9200/logstash-2016.09.16/rtds/_mapping?pretty
{
  "logstash-2016.09.16" : {
    "mappings" : {
      "rtds" : {
        "dynamic" : "false",
        "_all" : {
          "enabled" : false
        },
        "properties" : {
          "@timestamp" : {
            "type" : "date",
            "format" : "strict_date_optional_time||epoch_millis"
          },
          "@version" : {
            "type" : "string",
            "index" : "no",
            "doc_values" : true
          },
          "content" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "host" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "message" : {
            "type" : "string",
            "index" : "no",
            "doc_values" : true
          },
          "path" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "tags" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "type" : {
            "type" : "string",
            "index" : "not_analyzed"
          }
        }
      }
    }
  }
}

```

You can see there's no `date` field in this mapping.

But When I search, the `date` field appeared:

```auto
 curl localhost:9200/logstash-2016.09.16/rtds/_search?pretty
{
  "took" : 1093,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 2624596,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "logstash-2016.09.16",
      "_type" : "rtds",
      "_id" : "AVcwSvrWxFnTKGlIg7xt",
      "_score" : 1.0,
      "_source" : {
        "@timestamp" : "2016-09-16T00:00:01.276Z",
        "@version" : "1",
        "path" : "/var/log/rtds/rtds.log",
        "host" : "kaishan",
        "type" : "rtds",
        "tags" : ["rtds", "vertx", "throttled"],
        "date" : "2016-09-16 08:00:01,276",
        "loglevel" : "ERROR",
        "content" : "找不到对应的iid信息：12 ,sid = 00003310 ,eid = 00003310",
        "subject" : "找不到对应的iid信息：12 ,sid = 00003310 ,eid = 00003310"
      }
    }, {
      "_index" : "logstash-2016.09.16",
      "_type" : "rtds",
      "_id" : "AVcwSvrWxFnTKGlIg7x5",
      "_score" : 1.0,
      "_source" : {
        "@timestamp" : "2016-09-16T00:00:01.374Z",
        "@version" : "1",
        "path" : "/var/log/rtds/rtds.log",
        "host" : "kaishan",
        "type" : "rtds",
        "tags" : ["rtds", "vertx", "throttled"],
        "date" : "2016-09-16 08:00:01,374",
        "loglevel" : "ERROR",
        "content" : "找不到对应的iid信息：5 ,sid = 00002134 ,eid = 00002134",
        "subject" : "找不到对应的iid信息：5 ,sid = 00002134 ,eid = 00002134"
      }
    }
...

```

You can see the `date` appeared in the `_source`. What's my fault?

---

<div class="post-metadata">

### Author: ![abcfy2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abcfy2/32/453_2.png) [@abcfy2](https://discuss.elastic.co/u/abcfy2)
#### Post date: [September 16, 2016, 2:27pm UTC](https://discuss.elastic.co/t/solved-elasticsearch-mapping-dynamic-false-not-working/60720/2 "2016-09-16T14:27:16Z")

</div>

And here is my dynamic template setting:

```json
curl localhost:9200/_template/logstash?pretty
{
  "logstash" : {
    "order" : 0,
    "template" : "logstash-*",
    "settings" : {
      "index" : {
        "number_of_shards" : "5",
        "number_of_replicas" : "1",
        "refresh_interval" : "5s"
      }
    },
    "mappings" : {
      "_default_" : {
        "dynamic" : "false",
        "_all" : {
          "enabled" : false
        },
        "properties" : {
          "path" : {
            "index" : "not_analyzed",
            "type" : "string",
            "doc_values" : true
          },
          "@timestamp" : {
            "index" : "not_analyzed",
            "type" : "date",
            "doc_values" : true
          },
          "@version" : {
            "index" : "no",
            "type" : "string",
            "doc_values" : true
          },
          "host" : {
            "index" : "not_analyzed",
            "type" : "string",
            "doc_values" : true
          },
          "type" : {
            "index" : "not_analyzed",
            "type" : "string",
            "doc_values" : true
          },
          "message" : {
            "index" : "no",
            "type" : "string",
            "doc_values" : true
          },
          "content" : {
            "index" : "not_analyzed",
            "type" : "string",
            "doc_values" : true
          },
          "tags" : {
            "index" : "not_analyzed",
            "type" : "string",
            "doc_values" : true
          }
        }
      }
  }
}

```

---

<div class="post-metadata">

### Author: ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)
#### Post date: [September 16, 2016, 2:47pm UTC](https://discuss.elastic.co/t/solved-elasticsearch-mapping-dynamic-false-not-working/60720/3 "2016-09-16T14:47:25Z")

</div>

The date field isn't indexed, but it remains in the original `_source`. The source is the original JSON document that you sent to Elasticsearch, which is never modified. So that's why you see it.

But if you were to execute a search against the date field directly, you won't see any results, as none of the data was indexed.

---

<div class="post-metadata">

### Author: ![abcfy2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abcfy2/32/453_2.png) [@abcfy2](https://discuss.elastic.co/u/abcfy2)
#### Post date: [September 16, 2016, 2:49pm UTC](https://discuss.elastic.co/t/solved-elasticsearch-mapping-dynamic-false-not-working/60720/4 "2016-09-16T14:49:44Z")

</div>

Aha, I've got it. Thank you for your answer.

---

<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:19pm UTC](https://discuss.elastic.co/t/solved-elasticsearch-mapping-dynamic-false-not-working/60720/5 "2017-07-05T22:19:35Z")

</div>


