# Dynamic mapping templates: can it match on nesting depth?

**URL:** <https://discuss.elastic.co/t/dynamic-mapping-templates-can-it-match-on-nesting-depth/159619>\
**Category:** Elasticsearch\
**Created:** [December 5, 2018, 11:06pm UTC](https://discuss.elastic.co/t/dynamic-mapping-templates-can-it-match-on-nesting-depth/159619 "2018-12-05T23:06:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chillenious](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chillenious/32/37251_2.png) [@chillenious](https://discuss.elastic.co/u/chillenious)\
**Post date:** [December 5, 2018, 11:06pm UTC](https://discuss.elastic.co/t/dynamic-mapping-templates-can-it-match-on-nesting-depth/159619/1 "2018-12-05T23:06:18Z")

</div>

Hi!

I'm using nested properties as a way to scope indexing data for different audiences. For example:

```
{
  "internal": {
    "author": "Mikey Mike",
    "status": "RETIRED"
  },
  "extcorp": {
    "name": "cool stuff",
    "subject": "LANG"
  }

```

}

should have a (partial) mapping of:

```
{
  "mappings": {
    "_doc": {
      "properties": {
        "internal": {
          "type": "nested" 
        },
        "extcorp": {
          "type": "nested" 
        }
      }
    }
  }
}

```

The properties nested further would be part of the nested docs, and hence not denoted as nested.

I know that these nested props are always on the first level of nesting. Is there a way to write a dynamic mapping template that matches this first level (only) and instructs ES to index these as nested props?

Thanks!

Eelco

---

<div class="post-metadata">

**Author:** ![chillenious](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chillenious/32/37251_2.png) [@chillenious](https://discuss.elastic.co/u/chillenious)\
**Post date:** [December 7, 2018, 10:14pm UTC](https://discuss.elastic.co/t/dynamic-mapping-templates-can-it-match-on-nesting-depth/159619/2 "2018-12-07T22:14:03Z")

</div>

bump?

---

<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:** [January 4, 2019, 10:14pm UTC](https://discuss.elastic.co/t/dynamic-mapping-templates-can-it-match-on-nesting-depth/159619/3 "2019-01-04T22:14:08Z")

</div>

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