I'm not sure if this is something that is doable in a single Query
Here is the gist
Essentially I have following relationship
Parent (catentry) - one to many child (attributes) - one to many child
(attrvalues)
For a given parent entry I want to get all associated childs (attributes)
and all child documents of parent attributes? is is doable in a single
Query?
For a given parent entry I want to get all associated childs (attributes)
and all child documents of parent attributes? is is doable in a single
Query?
Hi Hariharan,
as far as I know, it's not. I think you'll need two round trips to get
parents and children. And for their children again one more.
If you only need the child documents for a limited number of parents,
you can use a multi search request to gather the corresponding children:
This is how I solved a simpler problem with just one additional level
(parent/child), where I needed the child docs only for the top-n parent
docs to be displayed. First search on parents, then take the top-n
parents and build a multi search over the child docs with a term query
on the "_parent" field for each parent doc. The multi search response
contains the list of child docs in the same order, so it's easy to map
them back to the list of parent docs.
In my scenario it's fast enough, though it takes two round trips instead
of just one. Also, if you need to get the child docs of a large list of
parent docs, this is probably not the way to go, I guess. Maybe somebody
comes up with a more elegant solution for that.
Actually after I included routing to both child and child's child and run following Query I get everything associated to top level parent, is this an option to get all the sub documents associated to a top level parent?
On Saturday, May 18, 2013 4:56:33 AM UTC-5, Hannes Korte wrote:
On 18.05.2013 03:07, Hariharan Vadivelu wrote:
For a given parent entry I want to get all associated childs
(attributes)
and all child documents of parent attributes? is is doable in a single
Query?
Hi Hariharan,
as far as I know, it's not. I think you'll need two round trips to get
parents and children. And for their children again one more.
This is how I solved a simpler problem with just one additional level
(parent/child), where I needed the child docs only for the top-n parent
docs to be displayed. First search on parents, then take the top-n
parents and build a multi search over the child docs with a term query
on the "_parent" field for each parent doc. The multi search response
contains the list of child docs in the same order, so it's easy to map
them back to the list of parent docs.
In my scenario it's fast enough, though it takes two round trips instead
of just one. Also, if you need to get the child docs of a large list of
parent docs, this is probably not the way to go, I guess. Maybe somebody
comes up with a more elegant solution for that.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.