What is the recommended way to retrieve documents in a parent child relationship

Hi,

Let's say I have 2 types - Parent & Child with a parent / child
relationship.

I want to get data that is similar to nested documents, i.e. for each
document I get from the parent I want to get all of its children as well.

What I thought of doing is to first query for the documents in the parent,
get all their IDs and then query from the child documents all those that
are children of the requested parents.
I maintain a parent field in the child document and query for children
whose parent field is any of the parents I got.

Hope I've made myself clear.

Is there a better way to achieve that?

Thanks
Ron

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Not really answer but my thoughts.

First, parent/child in elasticsearch is built for that need. I don't see why you need to build something else yourself.

Then, the main question is to me: "do I REALLY need relation between documents in a NoSQL world?"
It depends on your needs but I have often seen people trying to implement a Document oriented NoSQL solution with the same approach as relationnal database. So, before taking that decision, check that you really need it.

(Not saying that it's not a real need in your case).

My 2 cents.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 nov. 2013 à 13:01, Ron Sher ron.sher@gmail.com a écrit :

Hi,

Let's say I have 2 types - Parent & Child with a parent / child relationship.

I want to get data that is similar to nested documents, i.e. for each document I get from the parent I want to get all of its children as well.

What I thought of doing is to first query for the documents in the parent, get all their IDs and then query from the child documents all those that are children of the requested parents.
I maintain a parent field in the child document and query for children whose parent field is any of the parents I got.

Hope I've made myself clear.

Is there a better way to achieve that?

Thanks
Ron

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.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks for your feedback.
I can't really reveal the business case here, but assume that I do need it.
We also thought about using nested documents (which answer the query need),
but didn't use it since the child is updated in a much higher rate than the
parent and we didn't want to update the parent each time.

On Tuesday, November 5, 2013 2:48:20 PM UTC+2, David Pilato wrote:

Not really answer but my thoughts.

First, parent/child in elasticsearch is built for that need. I don't see
why you need to build something else yourself.

Then, the main question is to me: "do I REALLY need relation between
documents in a NoSQL world?"
It depends on your needs but I have often seen people trying to implement
a Document oriented NoSQL solution with the same approach as relationnal
database. So, before taking that decision, check that you really need it.

(Not saying that it's not a real need in your case).

My 2 cents.

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 nov. 2013 à 13:01, Ron Sher <ron....@gmail.com <javascript:>> a
écrit :

Hi,

Let's say I have 2 types - Parent & Child with a parent / child
relationship.

I want to get data that is similar to nested documents, i.e. for each
document I get from the parent I want to get all of its children as well.

What I thought of doing is to first query for the documents in the parent,
get all their IDs and then query from the child documents all those that
are children of the requested parents.
I maintain a parent field in the child document and query for children
whose parent field is any of the parents I got.

Hope I've made myself clear.

Is there a better way to achieve that?

Thanks
Ron

--
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 elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

I would like to know the answer as well.

I'm in the same boat. Nested document ingest was too slow and now we're using parent/child. I currently get all the parent IDs and then do a multi-search request for all the children for each of those parent IDs.