# Bug?: nested object mapping won't include both include\_in\_parent and include\_in\_root

**URL:** <https://discuss.elastic.co/t/bug-nested-object-mapping-wont-include-both-include-in-parent-and-include-in-root/245650>\
**Category:** Elasticsearch\
**Created:** [August 19, 2020, 4:17pm UTC](https://discuss.elastic.co/t/bug-nested-object-mapping-wont-include-both-include-in-parent-and-include-in-root/245650 "2020-08-19T16:17:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luke\_Nezda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/luke_nezda/32/47152_2.png) [@Luke\_Nezda](https://discuss.elastic.co/u/Luke_Nezda)\
**Post date:** [August 19, 2020, 4:17pm UTC](https://discuss.elastic.co/t/bug-nested-object-mapping-wont-include-both-include-in-parent-and-include-in-root/245650/1 "2020-08-19T16:17:16Z")

</div>

When I specify a `nested` `object` mapping with **both** `include_in_parent` and `include_in_root` it only uses `include_in_parent`. This feels like a bug. (Elasticsearch version 7.8.0)

Please advise.  
- Luke

Test case

```auto
PUT bar
{
  "mappings": {
      "properties" : {
        "user" : {
          "type" : "nested",
          "include_in_parent" : true,
          "include_in_root" : true,
          "properties" : {
            "first_name" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "last_name" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "email": {
              "type" : "nested",
              "include_in_parent" : true,
              "include_in_root" : true,
              "properties" : {
                "username" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                },
                "domain" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                },
                "email" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        }
      }
  }
}

PUT bar/_doc/1
{
  "user": {
    "first_name": "Luke",
    "last_name": "Nezda",
    "email": {
      "username": "luke",
      "domain": "example.com",
      "email": "luke@example.com"
    }
  }
}

GET bar

```

returns mapping without `"include_in_root" : true,`. I think this used to work?

```auto
{
  "bar" : {
    "aliases" : { },
    "mappings" : {
      "properties" : {
        "user" : {
          "type" : "nested",
          "include_in_parent" : true,
          "properties" : {
            "email" : {
              "type" : "nested",
              "include_in_parent" : true,
              "properties" : {
                "domain" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                },
                "email" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                },
                "username" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "first_name" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "last_name" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            }
          }
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1597853300876",
        "number_of_shards" : "1",
        "number_of_replicas" : "1",
        "uuid" : "LXSomCE-SZmEv4AT0ZxDiw",
        "version" : {
          "created" : "7080099"
        },
        "provided_name" : "bar"
      }
    }
  }
}

```

---

<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 16, 2020, 4:17pm UTC](https://discuss.elastic.co/t/bug-nested-object-mapping-wont-include-both-include-in-parent-and-include-in-root/245650/2 "2020-09-16T16:17:20Z")

</div>

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