# How best to do a mapping?

**URL:** https://discuss.elastic.co/t/how-best-to-do-a-mapping/27768
**Category:** Elasticsearch
**Created:** [August 20, 2015, 3:06pm UTC](https://discuss.elastic.co/t/how-best-to-do-a-mapping/27768 "2015-08-20T15:06:45Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![dceder906](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dceder906](https://discuss.elastic.co/u/dceder906)
#### Post date: [August 20, 2015, 3:06pm UTC](https://discuss.elastic.co/t/how-best-to-do-a-mapping/27768/1 "2015-08-20T15:06:45Z")

</div>

Who can give me a reasonable suggestion to do a mapping that will optimize an analytics query?

My entities are: Document(single, unique instance)  
Document Request(parent is a single Document, can be zero or more)  
NavElement(parent is a single Document; has a PathCode field to be used as a field in the aggregation)

I need an aggregation that produces a DataTable chart showing the count of DocumentRequests for each combo of Document and PathCode, and these counts should be bucketed by the date the DocumentRequest was created.

---

<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: [July 5, 2017, 11:54pm UTC](https://discuss.elastic.co/t/how-best-to-do-a-mapping/27768/2 "2017-07-05T23:54:52Z")

</div>


