# How to get all docs in a family?

**URL:** <https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625>\
**Category:** Elasticsearch\
**Created:** [January 14, 2015, 6:51am UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625 "2015-01-14T06:51:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [January 14, 2015, 6:51am UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/1 "2015-01-14T06:51:47Z")

</div>

Hi,  
I have question on document relations

one document can have multiple child's. and now I have to address below  
searches and achieve the mentioned expected results .

1. 

search on any child documents(meaning have a query that qualifies child  
documents) and retrieve the child ,parent and all of the child's of the  
parents

1. 

search on any parent documents and retrieve parent and all of the child  
documents

1. search on any parent documents and just retrieve only qualified parent  
documents

2. search on any child documents and just retrieve only qualified child  
documents

Is there any existing feature that help in achieving this ? any ideas  
/thoughts would be very useful ?  
also please provide some sample code if possible

--  
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/2acc2765-2fcf-4a11-b6ab-feecb1d02921%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2acc2765-2fcf-4a11-b6ab-feecb1d02921%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![drjz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drjz/32/972_2.png) [@drjz](https://discuss.elastic.co/u/drjz)\
**Post date:** [January 14, 2015, 8:57am UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/2 "2015-01-14T08:57:44Z")

</div>

1. 

has child  
query: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-has-child-query.html)

1. 

has parent  
query: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-has-parent-query.html)

1. 

has parent query + fields parameter

1. 

has child query + fields parameter

Check [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/relations.html)

/JZ

On Wednesday, January 14, 2015 at 7:51:47 AM UTC+1, buddarapu nagaraju  
wrote:

> Hi,  
> I have question on document relations
> 
> one document can have multiple child's. and now I have to address below  
> searches and achieve the mentioned expected results .
> 
> 1. 
> 
> search on any child documents(meaning have a query that qualifies child  
> documents) and retrieve the child ,parent and all of the child's of the  
> parents
> 
> 1. 
> 
> search on any parent documents and retrieve parent and all of the child  
> documents
> 
> 1. search on any parent documents and just retrieve only qualified parent  
> documents
> 
> 2. search on any child documents and just retrieve only qualified child  
> documents
> 
> Is there any existing feature that help in achieving this ? any ideas  
> /thoughts would be very useful ?  
> also please provide some sample code if possible

--  
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/b7e564f3-9338-4078-93ba-34fa1e208735%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b7e564f3-9338-4078-93ba-34fa1e208735%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![drjz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drjz/32/972_2.png) [@drjz](https://discuss.elastic.co/u/drjz)\
**Post date:** [January 14, 2015, 9:02am UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/3 "2015-01-14T09:02:32Z")

</div>

1. 

has child query:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

1. 

has parent query:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

1. 

has parent query + exists filter on parent type

1. 

has child query + exists filter on child type

Check

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

/JZ

On Wednesday, January 14, 2015 at 7:51:47 AM UTC+1, buddarapu nagaraju  
wrote:

> Hi,  
> I have question on document relations
> 
> one document can have multiple child's. and now I have to address below  
> searches and achieve the mentioned expected results .
> 
> 1. 
> 
> search on any child documents(meaning have a query that qualifies child  
> documents) and retrieve the child ,parent and all of the child's of the  
> parents
> 
> 1. 
> 
> search on any parent documents and retrieve parent and all of the child  
> documents
> 
> 1. search on any parent documents and just retrieve only qualified parent  
> documents
> 
> 2. search on any child documents and just retrieve only qualified child  
> documents
> 
> Is there any existing feature that help in achieving this ? any ideas  
> /thoughts would be very useful ?  
> also please provide some sample code if possible

--  
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/294eaab3-7d6d-455e-98fc-c79466d59fce%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/294eaab3-7d6d-455e-98fc-c79466d59fce%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [January 14, 2015, 9:16am UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/4 "2015-01-14T09:16:00Z")

</div>

All I will be knowing in API request is bool params to know whether to get  
family docs or not and query that user entered so I need to construct query  
that gets all family documents for qualified documents for given query if  
bool param is true and another query that just get the qualified documents

On Wednesday, 14 January 2015 01:51:47 UTC-5, buddarapu nagaraju wrote:

> Hi,  
> I have question on document relations
> 
> one document can have multiple child's. and now I have to address below  
> searches and achieve the mentioned expected results .
> 
> 1. 
> 
> search on any child documents(meaning have a query that qualifies child  
> documents) and retrieve the child ,parent and all of the child's of the  
> parents
> 
> 1. 
> 
> search on any parent documents and retrieve parent and all of the child  
> documents
> 
> 1. search on any parent documents and just retrieve only qualified parent  
> documents
> 
> 2. search on any child documents and just retrieve only qualified child  
> documents
> 
> Is there any existing feature that help in achieving this ? any ideas  
> /thoughts would be very useful ?  
> also please provide some sample code if possible

--  
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/3d2af72d-adfc-4b81-8728-b9a325e69e91%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3d2af72d-adfc-4b81-8728-b9a325e69e91%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [January 14, 2015, 3:36pm UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/5 "2015-01-14T15:36:38Z")

</div>

If some one has some ideas please let me know

On Wednesday, 14 January 2015 04:16:00 UTC-5, buddarapu nagaraju wrote:

> All I will be knowing in API request is bool params to know whether to get  
> family docs or not and query that user entered so I need to construct query  
> that gets all family documents for qualified documents for given query if  
> bool param is true and another query that just get the qualified documents
> 
> On Wednesday, 14 January 2015 01:51:47 UTC-5, buddarapu nagaraju wrote:
> 
> > Hi,  
> > I have question on document relations
> > 
> > one document can have multiple child's. and now I have to address below  
> > searches and achieve the mentioned expected results .
> > 
> > 1. 
> > 
> > search on any child documents(meaning have a query that qualifies child  
> > documents) and retrieve the child ,parent and all of the child's of the  
> > parents
> > 
> > 1. 
> > 
> > search on any parent documents and retrieve parent and all of the child  
> > documents
> > 
> > 1. search on any parent documents and just retrieve only qualified parent  
> > documents
> > 
> > 2. search on any child documents and just retrieve only qualified child  
> > documents
> > 
> > Is there any existing feature that help in achieving this ? any ideas  
> > /thoughts would be very useful ?  
> > also please provide some sample code if possible

--  
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/71c19344-017b-4341-96e6-be003cb2be3e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/71c19344-017b-4341-96e6-be003cb2be3e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ed\_Kim](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@Ed\_Kim](https://discuss.elastic.co/u/Ed_Kim)\
**Post date:** [January 14, 2015, 7:31pm UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/6 "2015-01-14T19:31:22Z")

</div>

I'm not sure if you can fetch both parent/child. You can certainly try by  
querying against the entire index (and therefore querying against your  
parent/child types), but we've never had any success with this. What we did  
to get around this was to denormalize the child documents, and let the  
parent be used only for matching purposes.

On Wednesday, January 14, 2015 at 7:36:38 AM UTC-8, buddarapu nagaraju  
wrote:

> If some one has some ideas please let me know
> 
> On Wednesday, 14 January 2015 04:16:00 UTC-5, buddarapu nagaraju wrote:
> 
> > All I will be knowing in API request is bool params to know whether to  
> > get family docs or not and query that user entered so I need to construct  
> > query that gets all family documents for qualified documents for given  
> > query if bool param is true and another query that just get the qualified  
> > documents
> > 
> > On Wednesday, 14 January 2015 01:51:47 UTC-5, buddarapu nagaraju wrote:
> > 
> > > Hi,  
> > > I have question on document relations
> > > 
> > > one document can have multiple child's. and now I have to address below  
> > > searches and achieve the mentioned expected results .
> > > 
> > > 1. 
> > > 
> > > search on any child documents(meaning have a query that qualifies child  
> > > documents) and retrieve the child ,parent and all of the child's of the  
> > > parents
> > > 
> > > 1. 
> > > 
> > > search on any parent documents and retrieve parent and all of the child  
> > > documents
> > > 
> > > 1. search on any parent documents and just retrieve only qualified  
> > > parent documents
> > > 
> > > 2. search on any child documents and just retrieve only qualified child  
> > > documents
> > > 
> > > Is there any existing feature that help in achieving this ? any ideas  
> > > /thoughts would be very useful ?  
> > > also please provide some sample code if possible

--  
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/0649a861-a235-49c4-9556-18b514690fff%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0649a861-a235-49c4-9556-18b514690fff%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [January 14, 2015, 7:39pm UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/7 "2015-01-14T19:39:41Z")

</div>

my understanding is nested objects (including nested filter and join) also  
doesnt help in this regard , correct me if am wrong

On Wednesday, 14 January 2015 14:31:22 UTC-5, Ed Kim wrote:

> I'm not sure if you can fetch both parent/child. You can certainly try by  
> querying against the entire index (and therefore querying against your  
> parent/child types), but we've never had any success with this. What we did  
> to get around this was to denormalize the child documents, and let the  
> parent be used only for matching purposes.
> 
> On Wednesday, January 14, 2015 at 7:36:38 AM UTC-8, buddarapu nagaraju  
> wrote:
> 
> > If some one has some ideas please let me know
> > 
> > On Wednesday, 14 January 2015 04:16:00 UTC-5, buddarapu nagaraju wrote:
> > 
> > > All I will be knowing in API request is bool params to know whether to  
> > > get family docs or not and query that user entered so I need to construct  
> > > query that gets all family documents for qualified documents for given  
> > > query if bool param is true and another query that just get the qualified  
> > > documents
> > > 
> > > On Wednesday, 14 January 2015 01:51:47 UTC-5, buddarapu nagaraju wrote:
> > > 
> > > > Hi,  
> > > > I have question on document relations
> > > > 
> > > > one document can have multiple child's. and now I have to address below  
> > > > searches and achieve the mentioned expected results .
> > > > 
> > > > 1. 
> > > > 
> > > > search on any child documents(meaning have a query that qualifies child  
> > > > documents) and retrieve the child ,parent and all of the child's of the  
> > > > parents
> > > > 
> > > > 1. 
> > > > 
> > > > search on any parent documents and retrieve parent and all of the child  
> > > > documents
> > > > 
> > > > 1. search on any parent documents and just retrieve only qualified  
> > > > parent documents
> > > > 
> > > > 2. search on any child documents and just retrieve only qualified child  
> > > > documents
> > > > 
> > > > Is there any existing feature that help in achieving this ? any ideas  
> > > > /thoughts would be very useful ?  
> > > > also please provide some sample code if possible

--  
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/9c45f125-bea8-4767-8eb5-69d7e5329972%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9c45f125-bea8-4767-8eb5-69d7e5329972%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ed\_Kim](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@Ed\_Kim](https://discuss.elastic.co/u/Ed_Kim)\
**Post date:** [January 14, 2015, 7:54pm UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/8 "2015-01-14T19:54:20Z")

</div>

If the relationship is very simple, I don't see why not. We originally  
decided to denormalize part of the parent document because we wanted to  
minimize the payload of the returning documents. A little while later, we  
found out we could omit fields from the document payload, but at that  
point, we had a smooth running app already, so we just noted this change  
into our research queue.

On Wednesday, January 14, 2015 at 11:39:42 AM UTC-8, buddarapu nagaraju  
wrote:

> my understanding is nested objects (including nested filter and join) also  
> doesnt help in this regard , correct me if am wrong
> 
> On Wednesday, 14 January 2015 14:31:22 UTC-5, Ed Kim wrote:
> 
> > I'm not sure if you can fetch both parent/child. You can certainly try by  
> > querying against the entire index (and therefore querying against your  
> > parent/child types), but we've never had any success with this. What we did  
> > to get around this was to denormalize the child documents, and let the  
> > parent be used only for matching purposes.
> > 
> > On Wednesday, January 14, 2015 at 7:36:38 AM UTC-8, buddarapu nagaraju  
> > wrote:
> > 
> > > If some one has some ideas please let me know
> > > 
> > > On Wednesday, 14 January 2015 04:16:00 UTC-5, buddarapu nagaraju wrote:
> > > 
> > > > All I will be knowing in API request is bool params to know whether to  
> > > > get family docs or not and query that user entered so I need to construct  
> > > > query that gets all family documents for qualified documents for given  
> > > > query if bool param is true and another query that just get the qualified  
> > > > documents
> > > > 
> > > > On Wednesday, 14 January 2015 01:51:47 UTC-5, buddarapu nagaraju wrote:
> > > > 
> > > > > Hi,  
> > > > > I have question on document relations
> > > > > 
> > > > > one document can have multiple child's. and now I have to address  
> > > > > below searches and achieve the mentioned expected results .
> > > > > 
> > > > > 1. 
> > > > > 
> > > > > search on any child documents(meaning have a query that qualifies  
> > > > > child documents) and retrieve the child ,parent and all of the child's of  
> > > > > the parents
> > > > > 
> > > > > 1. 
> > > > > 
> > > > > search on any parent documents and retrieve parent and all of the  
> > > > > child documents
> > > > > 
> > > > > 1. search on any parent documents and just retrieve only qualified  
> > > > > parent documents
> > > > > 
> > > > > 2. search on any child documents and just retrieve only qualified  
> > > > > child documents
> > > > > 
> > > > > Is there any existing feature that help in achieving this ? any ideas  
> > > > > /thoughts would be very useful ?  
> > > > > also please provide some sample code if possible

--  
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/aab1b66b-36aa-47a7-a467-2680b64c2e6a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aab1b66b-36aa-47a7-a467-2680b64c2e6a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![bvnagaraju](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@bvnagaraju](https://discuss.elastic.co/u/bvnagaraju)\
**Post date:** [January 14, 2015, 8:02pm UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/9 "2015-01-14T20:02:23Z")

</div>

okay .I am new to Elasticsearch and help me understand .

So you mean to say with the nested objects , you can return only inner  
objects if required or return entire object ?

If we can do this with nested objects , can you send me any sample code or  
example .

My applications relations deals only with one parent and multiple child's  
and child can have it own child's and so on .

Do you recommend using nested object for this kind of document relations ?

Actually now thinking that I can have fake document type which holds  
documents in a family and don't have to bother about the how deep the  
relation hierarchy is

Regards  
Nagaraju  
908 517 6981

On Wed, Jan 14, 2015 at 2:54 PM, Ed Kim [edkim81@gmail.com](mailto:edkim81@gmail.com) wrote:

> If the relationship is very simple, I don't see why not. We originally  
> decided to denormalize part of the parent document because we wanted to  
> minimize the payload of the returning documents. A little while later, we  
> found out we could omit fields from the document payload, but at that  
> point, we had a smooth running app already, so we just noted this change  
> into our research queue.
> 
> On Wednesday, January 14, 2015 at 11:39:42 AM UTC-8, buddarapu nagaraju  
> wrote:
> 
> > my understanding is nested objects (including nested filter and join)  
> > also doesnt help in this regard , correct me if am wrong
> > 
> > On Wednesday, 14 January 2015 14:31:22 UTC-5, Ed Kim wrote:
> > 
> > > I'm not sure if you can fetch both parent/child. You can certainly try  
> > > by querying against the entire index (and therefore querying against your  
> > > parent/child types), but we've never had any success with this. What we did  
> > > to get around this was to denormalize the child documents, and let the  
> > > parent be used only for matching purposes.
> > > 
> > > On Wednesday, January 14, 2015 at 7:36:38 AM UTC-8, buddarapu nagaraju  
> > > wrote:
> > > 
> > > > If some one has some ideas please let me know
> > > > 
> > > > On Wednesday, 14 January 2015 04:16:00 UTC-5, buddarapu nagaraju wrote:
> > > > 
> > > > > All I will be knowing in API request is bool params to know whether to  
> > > > > get family docs or not and query that user entered so I need to construct  
> > > > > query that gets all family documents for qualified documents for given  
> > > > > query if bool param is true and another query that just get the qualified  
> > > > > documents
> > > > > 
> > > > > On Wednesday, 14 January 2015 01:51:47 UTC-5, buddarapu nagaraju wrote:
> > > > > 
> > > > > > Hi,  
> > > > > > I have question on document relations
> > > > > > 
> > > > > > one document can have multiple child's. and now I have to address  
> > > > > > below searches and achieve the mentioned expected results .
> > > > > > 
> > > > > > 1. 
> > > > > > 
> > > > > > search on any child documents(meaning have a query that qualifies  
> > > > > > child documents) and retrieve the child ,parent and all of the child's of  
> > > > > > the parents
> > > > > > 
> > > > > > 1. 
> > > > > > 
> > > > > > search on any parent documents and retrieve parent and all of the  
> > > > > > child documents
> > > > > > 
> > > > > > 1. search on any parent documents and just retrieve only qualified  
> > > > > > parent documents
> > > > > > 
> > > > > > 2. search on any child documents and just retrieve only qualified  
> > > > > > child documents
> > > > > > 
> > > > > > Is there any existing feature that help in achieving this ? any ideas  
> > > > > > /thoughts would be very useful ?  
> > > > > > also please provide some sample code if possible
> > > > > 
> > > > > --  
> > > > > You received this message because you are subscribed to a topic in the  
> > > > > Google Groups "elasticsearch" group.  
> > > > > To unsubscribe from this topic, visit  
> > > > > [https://groups.google.com/d/topic/elasticsearch/X1JCuytcz0s/unsubscribe](https://groups.google.com/d/topic/elasticsearch/X1JCuytcz0s/unsubscribe).  
> > > > > To unsubscribe from this group and all its topics, 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/aab1b66b-36aa-47a7-a467-2680b64c2e6a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aab1b66b-36aa-47a7-a467-2680b64c2e6a%40googlegroups.com)  
> > > > > [https://groups.google.com/d/msgid/elasticsearch/aab1b66b-36aa-47a7-a467-2680b64c2e6a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/aab1b66b-36aa-47a7-a467-2680b64c2e6a%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/CAFtuXXK2LF1pvfTGkKakQmp6QBdg2dUCzYbKTseN3X7X-xCUfQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAFtuXXK2LF1pvfTGkKakQmp6QBdg2dUCzYbKTseN3X7X-xCUfQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ed\_Kim](https://avatars.discourse-cdn.com/v4/letter/e/53a042/32.png) [@Ed\_Kim](https://discuss.elastic.co/u/Ed_Kim)\
**Post date:** [January 14, 2015, 8:15pm UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/10 "2015-01-14T20:15:35Z")

</div>

I don't know how you access elasticsearch, so the best thing I can do is  
offer the resource on how to manipulate the payload returned on your  
request:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Both guides will show you how to exclude/include fields from \_source, which  
you can use to only get the fields you want. Afterwards, check whatever  
client you are using to see if it supports field inclusion/exclusion. For  
example, there's a 'setFetchSource' method that allows you to set  
exclusions in the Java client api for ES.

On Wednesday, January 14, 2015 at 12:04:56 PM UTC-8, buddarapu nagaraju  
wrote:

> okay .I am new to Elasticsearch and help me understand .
> 
> So you mean to say with the nested objects , you can return only inner  
> objects if required or return entire object ?
> 
> If we can do this with nested objects , can you send me any sample code or  
> example .
> 
> My applications relations deals only with one parent and multiple child's  
> and child can have it own child's and so on .
> 
> Do you recommend using nested object for this kind of document relations ?
> 
> Actually now thinking that I can have fake document type which holds  
> documents in a family and don't have to bother about the how deep the  
> relation hierarchy is
> 
> Regards  
> Nagaraju  
> 908 517 6981
> 
> On Wed, Jan 14, 2015 at 2:54 PM, Ed Kim \<[edk...@gmail.com](mailto:edk...@gmail.com) \<javascript:\>\>  
> wrote:
> 
> > If the relationship is very simple, I don't see why not. We originally  
> > decided to denormalize part of the parent document because we wanted to  
> > minimize the payload of the returning documents. A little while later, we  
> > found out we could omit fields from the document payload, but at that  
> > point, we had a smooth running app already, so we just noted this change  
> > into our research queue.
> > 
> > On Wednesday, January 14, 2015 at 11:39:42 AM UTC-8, buddarapu nagaraju  
> > wrote:
> > 
> > > my understanding is nested objects (including nested filter and join)  
> > > also doesnt help in this regard , correct me if am wrong
> > > 
> > > On Wednesday, 14 January 2015 14:31:22 UTC-5, Ed Kim wrote:
> > > 
> > > > I'm not sure if you can fetch both parent/child. You can certainly try  
> > > > by querying against the entire index (and therefore querying against your  
> > > > parent/child types), but we've never had any success with this. What we did  
> > > > to get around this was to denormalize the child documents, and let the  
> > > > parent be used only for matching purposes.
> > > > 
> > > > On Wednesday, January 14, 2015 at 7:36:38 AM UTC-8, buddarapu nagaraju  
> > > > wrote:
> > > > 
> > > > > If some one has some ideas please let me know
> > > > > 
> > > > > On Wednesday, 14 January 2015 04:16:00 UTC-5, buddarapu nagaraju wrote:
> > > > > 
> > > > > > All I will be knowing in API request is bool params to know whether  
> > > > > > to get family docs or not and query that user entered so I need to  
> > > > > > construct query that gets all family documents for qualified documents for  
> > > > > > given query if bool param is true and another query that just get the  
> > > > > > qualified documents
> > > > > > 
> > > > > > On Wednesday, 14 January 2015 01:51:47 UTC-5, buddarapu nagaraju  
> > > > > > wrote:
> > > > > > 
> > > > > > > Hi,  
> > > > > > > I have question on document relations
> > > > > > > 
> > > > > > > one document can have multiple child's. and now I have to address  
> > > > > > > below searches and achieve the mentioned expected results .
> > > > > > > 
> > > > > > > 1. 
> > > > > > > 
> > > > > > > search on any child documents(meaning have a query that qualifies  
> > > > > > > child documents) and retrieve the child ,parent and all of the child's of  
> > > > > > > the parents
> > > > > > > 
> > > > > > > 1. 
> > > > > > > 
> > > > > > > search on any parent documents and retrieve parent and all of the  
> > > > > > > child documents
> > > > > > > 
> > > > > > > 1. search on any parent documents and just retrieve only qualified  
> > > > > > > parent documents
> > > > > > > 
> > > > > > > 2. search on any child documents and just retrieve only qualified  
> > > > > > > child documents
> > > > > > > 
> > > > > > > Is there any existing feature that help in achieving this ? any  
> > > > > > > ideas /thoughts would be very useful ?  
> > > > > > > also please provide some sample code if possible
> > > > > > 
> > > > > > --  
> > > > > > You received this message because you are subscribed to a topic in the  
> > > > > > Google Groups "elasticsearch" group.  
> > > > > > To unsubscribe from this topic, visit  
> > > > > > [https://groups.google.com/d/topic/elasticsearch/X1JCuytcz0s/unsubscribe](https://groups.google.com/d/topic/elasticsearch/X1JCuytcz0s/unsubscribe).  
> > > > > > To unsubscribe from this group and all its topics, send an email to  
> > > > > > [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > > > > To view this discussion on the web visit  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/aab1b66b-36aa-47a7-a467-2680b64c2e6a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/aab1b66b-36aa-47a7-a467-2680b64c2e6a%40googlegroups.com)  
> > > > > > [https://groups.google.com/d/msgid/elasticsearch/aab1b66b-36aa-47a7-a467-2680b64c2e6a%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/aab1b66b-36aa-47a7-a467-2680b64c2e6a%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/999beef1-d16a-4cf7-87d8-9b7098e19339%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/999beef1-d16a-4cf7-87d8-9b7098e19339%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:38am UTC](https://discuss.elastic.co/t/how-to-get-all-docs-in-a-family/21625/11 "2017-07-06T00:38:53Z")

</div>


