# Need help to create mapping

**URL:** <https://discuss.elastic.co/t/need-help-to-create-mapping/141358>\
**Category:** Elasticsearch\
**Created:** [July 24, 2018, 10:48am UTC](https://discuss.elastic.co/t/need-help-to-create-mapping/141358 "2018-07-24T10:48:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![niraj\_pandey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_pandey/32/44034_2.png) [@niraj\_pandey](https://discuss.elastic.co/u/niraj_pandey)\
**Post date:** [July 24, 2018, 10:48am UTC](https://discuss.elastic.co/t/need-help-to-create-mapping/141358/1 "2018-07-24T10:48:33Z")

</div>

Hi,  
Could you please help me to create mapping for the json file in following format

{  
"2018-07-22 06:00" : {  
"Global Initiatives" : {  
"service1" : 0,  
"service2" : 0.02,  
"service3" : 10  
},  
"ABC" : {  
"service1" : 0,  
"service3" : 10  
}  
},  
"2018-07-22 08:00" : {  
"Global Initiatives" : {  
"service1" : 0.2,  
"service2" : 1.02,  
"service3" : 20  
},  
"ABC" : {  
"service1" : 30,  
"service3" : 100  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 24, 2018, 10:52am UTC](https://discuss.elastic.co/t/need-help-to-create-mapping/141358/2 "2018-07-24T10:52:31Z")

</div>

That looks like a bad format for data to index. Having dynamic keys in the document, e.g. `2018-07-22 08:00`, will quickly cause problems as you will create a large number of fields and hit limits. I would recommend you instead restructure the data with separate date fields.

---

<div class="post-metadata">

**Author:** ![niraj\_pandey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_pandey/32/44034_2.png) [@niraj\_pandey](https://discuss.elastic.co/u/niraj_pandey)\
**Post date:** [July 24, 2018, 11:03am UTC](https://discuss.elastic.co/t/need-help-to-create-mapping/141358/3 "2018-07-24T11:03:41Z")

</div>

You mean like this:

{  
"2018-07-22 06:00" : {  
"Global Initiatives" : {  
"service1" : 0,  
"service2" : 0.02,  
"service3" : 10  
}  
},  
"2018-07-22 06:00" : {  
"ABC" : {  
"service1" : 0,  
"service3" : 10  
}  
},  
"2018-07-22 08:00" : {  
"Global Initiatives" : {  
"service1" : 0.2,  
"service2" : 1.02,  
"service3" : 20  
}  
},  
"2018-07-22 08:00" : {  
"ABC" : {  
"service1" : 30,  
"service3" : 100  
}  
},  
}

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 24, 2018, 11:12am UTC](https://discuss.elastic.co/t/need-help-to-create-mapping/141358/4 "2018-07-24T11:12:43Z")

</div>

As I do not know your data nor how you want to query it it is tricky, but I was referring to something more like this:

```auto
{
  "date": "2018-07-22 06:00",
  "Global Initiatives" : {
    "service1" : 0,
    "service2" : 0.02,
    "service3" : 10
  },
  "ABC" : {
    "service1" : 0,
    "service3" : 10
  }
}

```

---

<div class="post-metadata">

**Author:** ![niraj\_pandey](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niraj_pandey/32/44034_2.png) [@niraj\_pandey](https://discuss.elastic.co/u/niraj_pandey)\
**Post date:** [July 24, 2018, 11:14am UTC](https://discuss.elastic.co/t/need-help-to-create-mapping/141358/5 "2018-07-24T11:14:45Z")

</div>

Ok how we would create the mapping for this format. Could you please guide me.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 24, 2018, 11:16am UTC](https://discuss.elastic.co/t/need-help-to-create-mapping/141358/6 "2018-07-24T11:16:19Z")

</div>

Have you looked at the examples available in [the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/mapping.html)?

---

<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 21, 2018, 11:16am UTC](https://discuss.elastic.co/t/need-help-to-create-mapping/141358/7 "2018-08-21T11:16:19Z")

</div>

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