Help with Parent/Child (gist included!)

(Paul Smith) #1

Hey all, a while back I posted this question about Parent/Child use case:

I've created a gist curl example to walk anyone through the thing I'm trying
to do:

In essense, I have 2 types, a 'doc' (parent) and a 'filecontent' (child)
within the same index. I'd like to be able to search both types in 1 query,
but if a match is found on the child, the results come back with the parent
record only, with all results sorted by fields in the parent.

I've got multiple issues here:

a) the final search query doesn't work, so clearly I have no idea what I'm
doing with respect to this top_children query
b) i'm not sure if I'm misinterpretting the way the parent/child is supposed
to work

I've set the child mapping to point to the parent type as indicated in the
docs for the _parent type. I'm presuming the routing is then taken care of
so the indexing of the child filecontent record can be routed to the same
shard as the parent (doc) record for searching later on.

I've tried hard to read the docs in elasticsearch on the parent/child
mapping, and I maybe just a bonehead here. This is a fairly critical use
case for us in the future, we don't index the file content at the moment
because it's hundreds of millions of records and an awful lot of content, so
do not want continuous meta-data record changes being indexed to require
retrieving and indexing file content over and over and over again.

Many thanks to anyone that can help here.


Paul Smith

(micuenta99) #2

Hi Paul,

I also am interested in this scenario ( 'doc' (parent) and a 'filecontent' (child))
At the end how you did it do?


(Paul Smith) #3

Still haven't solved this but only because I have not brought myself back
to working on this (for us it's a bit of a longer term project, not
pressing need right this second).

On 16 November 2011 03:24, micuenta99 wrote:

Hi Paul,

I also am interested in this scenario ( 'doc' (parent) and a 'filecontent'
At the end how you did it do?


View this message in context:
Sent from the ElasticSearch Users mailing list archive at

(system) #4