# Corss-index parent/child relationship

**URL:** <https://discuss.elastic.co/t/corss-index-parent-child-relationship/18313>\
**Category:** Elasticsearch\
**Created:** [June 25, 2014, 1:48am UTC](https://discuss.elastic.co/t/corss-index-parent-child-relationship/18313 "2014-06-25T01:48:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Drew\_Kutcharian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drew_kutcharian/32/742_2.png) [@Drew\_Kutcharian](https://discuss.elastic.co/u/Drew_Kutcharian)\
**Post date:** [June 25, 2014, 1:48am UTC](https://discuss.elastic.co/t/corss-index-parent-child-relationship/18313/1 "2014-06-25T01:48:34Z")

</div>

Hi!

Does ES support cross-index parent/child relationship? More specifically, can I have all the parents in one index (say users) and the children (say events) in a multiple time series style (managed by curator) indices? If so, how is this done? If not, what's the alternative?

Thanks,

Drew

--  
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/6AA466B5-D408-42D5-BC2A-E54BE30A830C%40venarc.com](https://groups.google.com/d/msgid/elasticsearch/6AA466B5-D408-42D5-BC2A-E54BE30A830C%40venarc.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Drew\_Kutcharian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drew_kutcharian/32/742_2.png) [@Drew\_Kutcharian](https://discuss.elastic.co/u/Drew_Kutcharian)\
**Post date:** [June 25, 2014, 8:49pm UTC](https://discuss.elastic.co/t/corss-index-parent-child-relationship/18313/2 "2014-06-25T20:49:20Z")

</div>

bump 😉

> On Jun 24, 2014, at 6:48 PM, Drew Kutcharian [drew@venarc.com](mailto:drew@venarc.com) wrote:
> 
> Hi!
> 
> Does ES support cross-index parent/child relationship? More specifically, can I have all the parents in one index (say users) and the children (say events) in a multiple time series style (managed by curator) indices? If so, how is this done? If not, what's the alternative?
> 
> Thanks,
> 
> Drew
> 
> --  
> 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/6AA466B5-D408-42D5-BC2A-E54BE30A830C%40venarc.com](https://groups.google.com/d/msgid/elasticsearch/6AA466B5-D408-42D5-BC2A-E54BE30A830C%40venarc.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/C2CA7D57-4B48-4FA3-AD44-299F75D6C3A4%40venarc.com](https://groups.google.com/d/msgid/elasticsearch/C2CA7D57-4B48-4FA3-AD44-299F75D6C3A4%40venarc.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Thomas\_Bolis](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomas_bolis/32/700_2.png) [@Thomas\_Bolis](https://discuss.elastic.co/u/Thomas_Bolis)\
**Post date:** [June 26, 2014, 7:10am UTC](https://discuss.elastic.co/t/corss-index-parent-child-relationship/18313/3 "2014-06-26T07:10:58Z")

</div>

Hi,

Unfortunately this is not supported by elasticsearch, the parent document  
and the child document must be under the same index or else the rounting  
will not be established. You can either try coping the parent document if  
they are not many or you can use an other way to split your data like with  
a hash function and to ensure that both parent and child document will be  
indexed into the same index.

Hope it helps  
Thomas

On Wednesday, 25 June 2014 04:48:48 UTC+3, Drew wrote:

> Hi!
> 
> Does ES support cross-index parent/child relationship? More specifically,  
> can I have all the parents in one index (say users) and the children (say  
> events) in a multiple time series style (managed by curator) indices? If  
> so, how is this done? If not, what’s the alternative?
> 
> Thanks,
> 
> Drew

--  
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/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [June 26, 2014, 3:14pm UTC](https://discuss.elastic.co/t/corss-index-parent-child-relationship/18313/4 "2014-06-26T15:14:46Z")

</div>

See PR #3278. Hopefully it will get merged into one of the next releases.

> <https://github.com/elastic/elasticsearch/pull/3278>
>
> This PR adds support for generating a terms filter based on the field values
> of …documents matching a specified lookup query/filter. The value of the 
> configurable "path" field is collected from the field data cache for each 
> document matching the lookup query/filter and is then used to filter the main 
> query. This is can also be called a join filter.
> 
> This PR abstracts the TermsLookup functionality in order to support multiple
> lookup methods. The existing functionality is moved into FieldTermsLookup and
> the new query based lookup is in QueryTermsLookup. All existing caching 
> functionality works with the new query based lookup for increased performance.
> 
> During testing of I found that one of the performance bottlenecks was 
> generating the Lucene TermsFilter on large sets of terms (probably since
> it sorts the terms). I have created a FieldDataTermsFilter that uses the
> field data cache to lookup value of the field being filtered and compare it to
> the set of gathered terms. This significantly increased performance at the 
> cost of higher memory usage. Currently a TermsFilter is used when the number
> of filtering terms is less than 1024 and the FieldDataTermsFilter is used
> for everything else. This should eventually be configurable or we need to
> perform some test to find the optimal value.
> 
> Examples:
> 
> Replicate a has\_child query by joining on the child's "pid" field to the
> parent's "id" field for each child that has the tag "something".
> 
> \`\`\`
> curl -XPOST 'http://localhost:9200/parentIndex/\_search' -d '{
> "query": {
> "constant\_score": {
> "filter": {
> "terms": {
> "id": {
> "index": "childIndex",
> "type": "childType",
> "path": "pid",
> "query": {
> "term": {
> "tag": "something"
> }
> }
> }
> }
> }
> }
> }
> }'
> \`\`\`
> 
> Lookup companies that offer products or services mentioning elasticsearch.
> Notice that products and services are kept in their own indices.
> 
> \`\`\`
> curl -XPOST 'http://localhost:9200/companies/\_search' -d '{
> "query": {
> "constant\_score": {
> "filter": {
> "terms": {
> "company\_id": {
> "indices": \["products", "services"\],
> "path": "company\_id",
> "filter": {
> "term": {
> "description": "elasticsearch"
> }
> }
> }
> }
> }
> }
> }
> }'
> \`\`\`

Thanks,  
Matt Weber

On Thu, Jun 26, 2014 at 12:10 AM, Thomas [thomas.bolis@gmail.com](mailto:thomas.bolis@gmail.com) wrote:

> Hi,
> 
> Unfortunately this is not supported by elasticsearch, the parent document  
> and the child document must be under the same index or else the rounting  
> will not be established. You can either try coping the parent document if  
> they are not many or you can use an other way to split your data like with  
> a hash function and to ensure that both parent and child document will be  
> indexed into the same index.
> 
> Hope it helps  
> Thomas
> 
> On Wednesday, 25 June 2014 04:48:48 UTC+3, Drew wrote:
> 
> > Hi!
> > 
> > Does ES support cross-index parent/child relationship? More specifically,  
> > can I have all the parents in one index (say users) and the children (say  
> > events) in a multiple time series style (managed by curator) indices? If  
> > so, how is this done? If not, what’s the alternative?
> > 
> > Thanks,
> > 
> > Drew
> 
> --  
> 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/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAJ3KEoDq74hQ-OSByFs2HotMtb7aAUfM1zfHwTaMBpQ542o0EA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDq74hQ-OSByFs2HotMtb7aAUfM1zfHwTaMBpQ542o0EA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Drew\_Kutcharian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drew_kutcharian/32/742_2.png) [@Drew\_Kutcharian](https://discuss.elastic.co/u/Drew_Kutcharian)\
**Post date:** [June 27, 2014, 2:20am UTC](https://discuss.elastic.co/t/corss-index-parent-child-relationship/18313/5 "2014-06-27T02:20:37Z")

</div>

Thanks Matt, that feature is exactly what we need. One thing I couldn't figure out was that I would be able to pass a routing key so only relevant shards would be queried, right?

On Jun 26, 2014, at 8:14 AM, Matt Weber [matt.weber@gmail.com](mailto:matt.weber@gmail.com) wrote:

> See PR #3278. Hopefully it will get merged into one of the next releases.
> 
> [Terms Lookup by Query/Filter (aka. Join Filter) by mattweber · Pull Request #3278 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/3278)
> 
> Thanks,  
> Matt Weber
> 
> On Thu, Jun 26, 2014 at 12:10 AM, Thomas [thomas.bolis@gmail.com](mailto:thomas.bolis@gmail.com) wrote:  
> Hi,
> 
> Unfortunately this is not supported by elasticsearch, the parent document and the child document must be under the same index or else the rounting will not be established. You can either try coping the parent document if they are not many or you can use an other way to split your data like with a hash function and to ensure that both parent and child document will be indexed into the same index.
> 
> Hope it helps  
> Thomas
> 
> On Wednesday, 25 June 2014 04:48:48 UTC+3, Drew wrote:  
> Hi!
> 
> Does ES support cross-index parent/child relationship? More specifically, can I have all the parents in one index (say users) and the children (say events) in a multiple time series style (managed by curator) indices? If so, how is this done? If not, what's the alternative?
> 
> Thanks,
> 
> Drew
> 
> --  
> 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/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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/CAJ3KEoDq74hQ-OSByFs2HotMtb7aAUfM1zfHwTaMBpQ542o0EA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDq74hQ-OSByFs2HotMtb7aAUfM1zfHwTaMBpQ542o0EA%40mail.gmail.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/0E6751DE-2040-4F12-829E-2F729E7DE053%40venarc.com](https://groups.google.com/d/msgid/elasticsearch/0E6751DE-2040-4F12-829E-2F729E7DE053%40venarc.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![mattweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattweber/32/44940_2.png) [@mattweber](https://discuss.elastic.co/u/mattweber)\
**Post date:** [June 27, 2014, 4:02am UTC](https://discuss.elastic.co/t/corss-index-parent-child-relationship/18313/6 "2014-06-27T04:02:23Z")

</div>

I have not tested routing but I did put that functionality in so it should  
work fine. Let me know if you have any issues!

Thanks,  
Matt Weber

On Thu, Jun 26, 2014 at 7:20 PM, Drew Kutcharian [drew@venarc.com](mailto:drew@venarc.com) wrote:

> Thanks Matt, that feature is exactly what we need. One thing I couldn’t  
> figure out was that I would be able to pass a routing key so only relevant  
> shards would be queried, right?
> 
> On Jun 26, 2014, at 8:14 AM, Matt Weber [matt.weber@gmail.com](mailto:matt.weber@gmail.com) wrote:
> 
> See PR #3278. Hopefully it will get merged into one of the next releases.
> 
> [Terms Lookup by Query/Filter (aka. Join Filter) by mattweber · Pull Request #3278 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/pull/3278)
> 
> Thanks,  
> Matt Weber
> 
> On Thu, Jun 26, 2014 at 12:10 AM, Thomas [thomas.bolis@gmail.com](mailto:thomas.bolis@gmail.com) wrote:
> 
> > Hi,
> > 
> > Unfortunately this is not supported by elasticsearch, the parent document  
> > and the child document must be under the same index or else the rounting  
> > will not be established. You can either try coping the parent document if  
> > they are not many or you can use an other way to split your data like with  
> > a hash function and to ensure that both parent and child document will be  
> > indexed into the same index.
> > 
> > Hope it helps  
> > Thomas
> > 
> > On Wednesday, 25 June 2014 04:48:48 UTC+3, Drew wrote:
> > 
> > > Hi!
> > > 
> > > Does ES support cross-index parent/child relationship? More  
> > > specifically, can I have all the parents in one index (say users) and the  
> > > children (say events) in a multiple time series style (managed by curator)  
> > > indices? If so, how is this done? If not, what’s the alternative?
> > > 
> > > Thanks,
> > > 
> > > Drew
> > 
> > --  
> > 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/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/d1d73ca5-8d7f-4515-83bb-87f956f5fd83%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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/CAJ3KEoDq74hQ-OSByFs2HotMtb7aAUfM1zfHwTaMBpQ542o0EA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDq74hQ-OSByFs2HotMtb7aAUfM1zfHwTaMBpQ542o0EA%40mail.gmail.com)  
> [https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDq74hQ-OSByFs2HotMtb7aAUfM1zfHwTaMBpQ542o0EA%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoDq74hQ-OSByFs2HotMtb7aAUfM1zfHwTaMBpQ542o0EA%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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/0E6751DE-2040-4F12-829E-2F729E7DE053%40venarc.com](https://groups.google.com/d/msgid/elasticsearch/0E6751DE-2040-4F12-829E-2F729E7DE053%40venarc.com)  
> [https://groups.google.com/d/msgid/elasticsearch/0E6751DE-2040-4F12-829E-2F729E7DE053%40venarc.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/0E6751DE-2040-4F12-829E-2F729E7DE053%40venarc.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAJ3KEoCpxwUw9510Cp7SWpQNA0Zs8kTY7bUcKWYDpW9mEgHYpw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAJ3KEoCpxwUw9510Cp7SWpQNA0Zs8kTY7bUcKWYDpW9mEgHYpw%40mail.gmail.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, 1:19am UTC](https://discuss.elastic.co/t/corss-index-parent-child-relationship/18313/7 "2017-07-06T01:19:24Z")

</div>


