Parent/child join approach?

Our ES data model includes an Entity parent document type and an EntityDetail child document type which has served us well; however, the big deficiency which I've postponed as long as possible hoping Lucene and Elasticsearch would implement is the dreaded parent/child join.

Unfortunately, my customer has been hammering us on it lately, so it looks like we're going to have to implement some kind of parent/child join solution, ourselves for certain queries where he wants relevance ranked hits across multiple child documents.

My first inclination was just to do the joins at our service layer, but then I was thinking an ES plugin approach might be a better solution.

Thoughts?

ES has parent/child structures - https://www.elastic.co/guide/en/elasticsearch/guide/master/parent-child.html

Or am I missing something?

Yes, as I mentioned, we are using ES parent/child documents which works fine for simple single field hits of any child document; however, the type of query my customer is looking for is for two or more fields that could be spread across any of the child child documents.

e.g. parent document represents a person and child documents represent details (e.g. surname, given name, hair color, eye color, gender, etc.) about that person. So, only return the person parent document when ( surname = "Smith" ) AND ( givenName = "John" OR "jon" OR "jack" ) AND ( gender = "male" ) AND ( hairColor = "black" ) but the fields could be spread across any number of child documents.

So, a join of the parent and child documents would be necessary to satisfy inter-child document AND'd hits.

Yeah, I missed that bit sorry :slight_smile:

Have you seen https://www.elastic.co/guide/en/elasticsearch/reference/2.3/query-dsl-has-parent-query.html at all?

Yes, that's what we are currently using, but again, that only returns a hit for a given child document--not two or more child documents. e.g. if surname is in one child document and given name is in another, then return the parent document; however, the has_parent query will only return the parent document if the surname and given name is in the same child document.