# How to restrict timestamp field in multi layer JSON where field with same name but different data types are present in second layer of JSON

**URL:** <https://discuss.elastic.co/t/how-to-restrict-timestamp-field-in-multi-layer-json-where-field-with-same-name-but-different-data-types-are-present-in-second-layer-of-json/158878>\
**Category:** Elasticsearch\
**Created:** [November 30, 2018, 9:47am UTC](https://discuss.elastic.co/t/how-to-restrict-timestamp-field-in-multi-layer-json-where-field-with-same-name-but-different-data-types-are-present-in-second-layer-of-json/158878 "2018-11-30T09:47:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sshekher](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@sshekher](https://discuss.elastic.co/u/sshekher)\
**Post date:** [November 30, 2018, 9:47am UTC](https://discuss.elastic.co/t/how-to-restrict-timestamp-field-in-multi-layer-json-where-field-with-same-name-but-different-data-types-are-present-in-second-layer-of-json/158878/1 "2018-11-30T09:47:16Z")

</div>

In my dynamic template I am adding field with name "timestamp" as of date type. It is later converted to epoch. now in a particular case there is one more field with name "timestamp" in second layer of multi layer JSON, for which epoch conversion is failing.  
I want to restrict Elasticsearch to consider the "timestamp" field in only at layer 1 of JSON.

IS there any configuration by which I can achieve this?

My Sample JSON:

> ```
> {  
> 
> ```
> 
> "transactionId":"gdfgkldgn-543vdk345j-dfgkndg",  
> "timestamp":"2018-11-16T17:01:29.535Z",  
> "eventName":"testing",  
> "[userId":"utest@test.com](mailto:userId%22:%22utest@test.com)",  
> "before":{  
> "userName":" test@test.address ",  
> "lastChanged":{  
> "date":"2018-11-16T17:01:10.249Z"  
> },  
> "lastSync":{  
> "TestingUser\_Manager":{  
> "timestamp":"2018-09-30T01:41:09.005-04:00"  
> }  
> }  
> }  
> }  
> In the above JSON the inner timestamp value is failing to convert to epoch.

Dynamic template: below mention as timestamp field in Dynamic Template.

> "timestamp\_data\_template":{  
> "match":"timestamp",  
> "mapping":{  
> "type":"long",  
> "store":"yes"  
> }  
> }

---

<div class="post-metadata">

**Author:** ![sshekher](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@sshekher](https://discuss.elastic.co/u/sshekher)\
**Post date:** [December 11, 2018, 6:01am UTC](https://discuss.elastic.co/t/how-to-restrict-timestamp-field-in-multi-layer-json-where-field-with-same-name-but-different-data-types-are-present-in-second-layer-of-json/158878/2 "2018-12-11T06:01:31Z")

</div>

Is there any configuration to limit where to look for timestamp field in JSON before sending it to elastic search.

---

<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 8, 2019, 6:01am UTC](https://discuss.elastic.co/t/how-to-restrict-timestamp-field-in-multi-layer-json-where-field-with-same-name-but-different-data-types-are-present-in-second-layer-of-json/158878/3 "2019-01-08T06:01:35Z")

</div>

Closed on January 8, 2019, 6:01am UTC

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