# Index.mapping.depth

**URL:** https://discuss.elastic.co/t/index-mapping-depth/145766
**Category:** Elasticsearch
**Created:** [August 23, 2018, 3:01pm UTC](https://discuss.elastic.co/t/index-mapping-depth/145766 "2018-08-23T15:01:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Max\_K](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Max\_K](https://discuss.elastic.co/u/Max_K)
#### Post date: [August 23, 2018, 3:01pm UTC](https://discuss.elastic.co/t/index-mapping-depth/145766/1 "2018-08-23T15:01:46Z")

</div>

Hello.  
Please clarify the functional index.mapping.depth.limit.  
From the [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#mapping-limit-settings](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html#mapping-limit-settings) documentation it seems that this option will limit the depth of the lower-level fields created by the dynamic mapping, and so . I need only the first two, I set the value to 2 and suddenly get an error  
`[WARN] [logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {: status => 400,: action => ["index", {: _id => nil,: _index => "3dash-2018.08.23",: _type => "doc",: _routing => nil}, # <LogStash :: Event: 0x290a2d39>],: response => {"index" => {"_ index" => "3dash-2018.08.23", "_type" => "doc", "_id" => " pDEcZ2UB9niMDQsqsMkQ "," status "=> 400," error "=> {" type "=>" illegal_argument_exception "," reason "=>" Limit of mapping depth [2] in index [3dash-2018.08.23] has exceeded due to object field [Response.OperationSystemList.Data] "}}}}`

If I do not use this option correctly, then how do I limit the dynamic mapping to the first two levels?  
Thx for answers.

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [August 23, 2018, 3:49pm UTC](https://discuss.elastic.co/t/index-mapping-depth/145766/2 "2018-08-23T15:49:34Z")

</div>

This option will limit the depth of fields, but in a way that rejects documents that have a too deep structure.

It looks like what you are after is to ignore fields that are more than 2 levels deep, which can be done this way with dynamic templates:

```auto
PUT test 
{
  "mappings": {
    "_doc": {
      "dynamic_templates": [
        {
          "deep_objects": {
            "match_mapping_type": "object",
            "path_match": "*.*",
            "mapping": {
              "type": "object",
              "enabled": false
            }
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![Max\_K](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Max\_K](https://discuss.elastic.co/u/Max_K)
#### Post date: [August 23, 2018, 3:52pm UTC](https://discuss.elastic.co/t/index-mapping-depth/145766/3 "2018-08-23T15:52:42Z")

</div>

Thank you for the explanation, try to do so.

---

<div class="post-metadata">

### Author: ![Max\_K](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Max\_K](https://discuss.elastic.co/u/Max_K)
#### Post date: [August 23, 2018, 4:05pm UTC](https://discuss.elastic.co/t/index-mapping-depth/145766/4 "2018-08-23T16:05:42Z")

</div>

> [@jpountz](#):
>
> "path\_match": "_._"

I correctly understand that if I need a third level, then the difference will be in `"path_match": "*. *. *"`?

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [August 27, 2018, 10:42am UTC](https://discuss.elastic.co/t/index-mapping-depth/145766/5 "2018-08-27T10:42:44Z")

</div>

This is correct.

---

<div class="post-metadata">

### Author: ![Max\_K](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@Max\_K](https://discuss.elastic.co/u/Max_K)
#### Post date: [August 27, 2018, 12:15pm UTC](https://discuss.elastic.co/t/index-mapping-depth/145766/6 "2018-08-27T12:15:42Z")

</div>

thank you for clarification!

---

<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: [September 24, 2018, 12:15pm UTC](https://discuss.elastic.co/t/index-mapping-depth/145766/7 "2018-09-24T12:15:44Z")

</div>

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