# Scrolling over Parent/Child Documents

**URL:** <https://discuss.elastic.co/t/scrolling-over-parent-child-documents/20437>\
**Category:** Elasticsearch\
**Created:** [October 26, 2014, 8:35pm UTC](https://discuss.elastic.co/t/scrolling-over-parent-child-documents/20437 "2014-10-26T20:35:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![govind201](https://avatars.discourse-cdn.com/v4/letter/g/8dc957/32.png) [@govind201](https://discuss.elastic.co/u/govind201)\
**Post date:** [October 26, 2014, 8:35pm UTC](https://discuss.elastic.co/t/scrolling-over-parent-child-documents/20437/1 "2014-10-26T20:35:48Z")

</div>

I have an index of ~500 million documents, which I'd like to "scroll"  
through either sorted by a common field (across multiple types), or by  
clustering parent-child documents together.

Here's how a typical set of documents is laid out:  
PARENT: {"id" : "PARENT\_ID1", "index" =\> "CommonIndex", "type" =\> "TypeA",  
"data" =\> {"parent\_id" : "PARENT\_ID1", "name" : ... } }  
CHILD1: {"id" : "CHILD\_ID1A", "index" =\> "CommonIndex", "type" =\> "TypeB",  
"parent" : "PARENT\_ID1", "data" =\> {"parent\_id" : "PARENT\_ID1", "name" :  
... } }  
CHILD2: {"id" : "CHILD\_ID1B", "index" =\> "CommonIndex", "type" =\> "TypeB",  
"parent" : "PARENT\_ID1", "data" =\> {"parent\_id" : "PARENT\_ID1", "name" :  
... } }  
CHILD3: {"id" : "CHILD\_ID1C", "index" =\> "CommonIndex", "type" =\> "TypeC",  
"parent" : "PARENT\_ID1", "data" =\> {"parent\_id" : "PARENT\_ID1", "name" :  
... } }

I'd like to retrieve parent and child documents clustered together, merge  
them, and store the merged result in a separate index.  
_Which leads me to my question_: is there a way to scan/scroll and retrieve  
parent-child documents bundled / clustered together?

--

_Alternative approach tried with partial success:_

FYI, I tried using "sort" with "scroll" (without "scan" set) on the  
"parent\_id" field as follows: _{sort =\> [{"parent\_id" =\> "desc"}]}_, as a  
shot in the dark. While the results did appear sorted at first glance, upon  
closer examination, I noticed that the results were at times out of order.  
Here's an extract of just the parent\_id fields printed:

7n3uxOf1dYUq  
7n3uxOf1dYUq  
7n3Zj2oadUKM  
7n3Zj2oadUKM  
7n3U2l0DkeYg  
7n3U2l0DkeYg  
7n3SOHKjAG2K --\> out of order  
7n3U2l0DkeYg  
7n3U2l0DkeYg

Thanks!

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/de41eda5-0b33-44e9-9951-b72dde7d7f85%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/de41eda5-0b33-44e9-9951-b72dde7d7f85%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:53am UTC](https://discuss.elastic.co/t/scrolling-over-parent-child-documents/20437/2 "2017-07-06T00:53:49Z")

</div>

Closed on July 6, 2017, 12:53am UTC


