# How to provide mapping for nested objects?

**URL:** <https://discuss.elastic.co/t/how-to-provide-mapping-for-nested-objects/91323>\
**Category:** Elasticsearch\
**Created:** [June 29, 2017, 5:23pm UTC](https://discuss.elastic.co/t/how-to-provide-mapping-for-nested-objects/91323 "2017-06-29T17:23:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaushah](https://avatars.discourse-cdn.com/v4/letter/k/dfb087/32.png) [@kaushah](https://discuss.elastic.co/u/kaushah)\
**Post date:** [June 29, 2017, 5:23pm UTC](https://discuss.elastic.co/t/how-to-provide-mapping-for-nested-objects/91323/1 "2017-06-29T17:23:50Z")

</div>

I'm using ElasticSearch 5.4  
My document is as follows:

```
{
"Tags" : { "key1" : "value1" , "key2" : "value2" , "key3":"value3" },
"NameArray" : [{
     "TimeStamp" : "2015-08-11T01:28:23.461Z",
     "Name" : ["Dan1", "Dan2"]
},
{
     "TimeStamp" : "2012-11-11T01:28:23.461Z",
     "Name" : ["John1", "John2"]
}
]
}

```

How should I define my mapping?

```
PUT index1
{
  "mappings": {
    "type1" : {
      "properties" : {
        "Tags" : {
          "type" : "nested"
        },
        "NameArray" : {
          "type" : "nested"
        },
        "NameArray.TimeStamp" : {
          "type" : "date"
        }
      }
    }
  }
}

```

I need TimeStamp to be of type date.  
How should the mapping be done?

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [July 7, 2017, 7:08am UTC](https://discuss.elastic.co/t/how-to-provide-mapping-for-nested-objects/91323/2 "2017-07-07T07:08:00Z")

</div>

You're looking for something like:

```auto
"NameArray" : {
   "type" : "nested",
   "properties": {
      "TimeStamp" : { "type" : "date" }
      "Name" : { "type" : "text" }
   }
}

```

---

<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:** [August 4, 2017, 7:08am UTC](https://discuss.elastic.co/t/how-to-provide-mapping-for-nested-objects/91323/3 "2017-08-04T07:08:07Z")

</div>

Closed on August 4, 2017, 7:08am UTC

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