# Indexing nested objects

**URL:** <https://discuss.elastic.co/t/indexing-nested-objects/4697>\
**Category:** Elasticsearch\
**Created:** [June 24, 2011, 2:57am UTC](https://discuss.elastic.co/t/indexing-nested-objects/4697 "2011-06-24T02:57:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Everton](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dan_everton/32/1865_2.png) [@Dan\_Everton](https://discuss.elastic.co/u/Dan_Everton)\
**Post date:** [June 24, 2011, 2:57am UTC](https://discuss.elastic.co/t/indexing-nested-objects/4697/1 "2011-06-24T02:57:52Z")

</div>

Howdy,

I've been reading through the mapping documentation for ES but haven't  
really found a good way to index nested structures without the having  
indexes created for all possible depths of nesting.

Here's an example document of what I'm talking about [https://gist.github.com/1044127](https://gist.github.com/1044127)

ES indexes this fine, but creates repeated mappings for each level of  
nesting like stackTrace.causedBy.causedBy.message which isn't ideal.  
What would be nice would be to do queries like  
"stackTrace.causedBy.message:FINDTHIS" and have ES search all messages  
down that stack trace hierarchy.

Can this be done? Or would it be better to restructure the documents  
so instead of nesting the causedBy, it's an array of causedBy?

Cheers,  
Dan

---

<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 6, 2017, 4:02am UTC](https://discuss.elastic.co/t/indexing-nested-objects/4697/2 "2017-07-06T04:02:47Z")

</div>


