# Indexing Hierarchical Couchbase Documents

**URL:** <https://discuss.elastic.co/t/indexing-hierarchical-couchbase-documents/70400>\
**Category:** Elasticsearch\
**Created:** [January 3, 2017, 7:45am UTC](https://discuss.elastic.co/t/indexing-hierarchical-couchbase-documents/70400 "2017-01-03T07:45:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [January 3, 2017, 9:19am UTC](https://discuss.elastic.co/t/indexing-hierarchical-couchbase-documents/70400/2 "2017-01-03T09:19:53Z")

</div>

From the example documents you supplied there's no indication that doc 2 should be related to doc 1.

You have 3 options :

- Collapse all source docs into a single "flat" JSON doc
- Collapse all source docs into a single "nested" JSON doc [1]
- Store parent and child source docs separately but relate them when you add them [2]

The decision process for why you would choose one approach over another is roughly this:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/b/b56cea352b3d9b5d8ea17615dd753a2f3cc6798e.png)

I'm unfamiliar with the couchbase plugin and to what extent it can be made to work with elasticsearch's parent/child indexing API.

[1] [https://www.elastic.co/guide/en/elasticsearch/guide/2.x/nested-objects.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/nested-objects.html)  
[2] [https://www.elastic.co/guide/en/elasticsearch/guide/2.x/parent-child.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/parent-child.html)

---

_[View the full topic](https://discuss.elastic.co/t/indexing-hierarchical-couchbase-documents/70400)._
