Query: Parents with at least x children of type y

Hello,
after some research without any results I have a question about
parent/child relations.

The case:

I have a parent of type "parent_type" which has children of different types
e.g. "child_type_1", "child_type_2", "child_type_3".

My Question is:

Is there any possibility to get only the parents which have at least x
children of type "child_type_2" with an specific value in an attribute.

e.g

parent_type: family
child_type_1: girl attribute:name
child_type_2: boy attribute:name
child_type_3: cat attribute:name

And i want to have all families which have at least three girls with name
"Jane".

Thank you for your help,
Alex

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/15c715f7-4414-424d-ae04-54bb77b7ddcf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sorry for bumping, but i need an answer, if it's posible to answer the
question above with elasticsearch

Am Donnerstag, 2. Januar 2014 15:22:32 UTC+1 schrieb Alexander Stautner:

Hello,
after some research without any results I have a question about
parent/child relations.

The case:

I have a parent of type "parent_type" which has children of different
types e.g. "child_type_1", "child_type_2", "child_type_3".

My Question is:

Is there any possibility to get only the parents which have at least x
children of type "child_type_2" with an specific value in an attribute.

e.g

parent_type: family
child_type_1: girl attribute:name
child_type_2: boy attribute:name
child_type_3: cat attribute:name

And i want to have all families which have at least three girls with name
"Jane".

Thank you for your help,
Alex

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6622897e-3e72-4db4-b4a0-4d8555c077e8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

I would probably add a num_of_children field in parent doc and update it when a new child is added or removed.

But I guess it depends on your actual use case!

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

Le 7 janv. 2014 à 08:15, Alexander Stautner alexander.stautner@gmail.com a écrit :

Sorry for bumping, but i need an answer, if it's posible to answer the question above with elasticsearch

Am Donnerstag, 2. Januar 2014 15:22:32 UTC+1 schrieb Alexander Stautner:

Hello,
after some research without any results I have a question about parent/child relations.

The case:

I have a parent of type "parent_type" which has children of different types e.g. "child_type_1", "child_type_2", "child_type_3".

My Question is:

Is there any possibility to get only the parents which have at least x children of type "child_type_2" with an specific value in an attribute.

e.g

parent_type: family
child_type_1: girl attribute:name
child_type_2: boy attribute:name
child_type_3: cat attribute:name

And i want to have all families which have at least three girls with name "Jane".

Thank you for your help,
Alex

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6622897e-3e72-4db4-b4a0-4d8555c077e8%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/85E9435C-F658-45A3-9F84-C9CE0EA697DB%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.

Changing the parent doc should be prevented, because there may be new
child_types added or old child_types may be removed and we want the
child_types be independed from the parent_type.

So it seems, that there is at the moment no way for doing suchs queries
with elasticsearch?

Thanks for helping.

Am Dienstag, 7. Januar 2014 10:39:41 UTC+1 schrieb David Pilato:

I would probably add a num_of_children field in parent doc and update it
when a new child is added or removed.

But I guess it depends on your actual use case!

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

Le 7 janv. 2014 à 08:15, Alexander Stautner <alexander...@gmail.com<javascript:>>
a écrit :

Sorry for bumping, but i need an answer, if it's posible to answer the
question above with elasticsearch

Am Donnerstag, 2. Januar 2014 15:22:32 UTC+1 schrieb Alexander Stautner:

Hello,
after some research without any results I have a question about
parent/child relations.

The case:

I have a parent of type "parent_type" which has children of different
types e.g. "child_type_1", "child_type_2", "child_type_3".

My Question is:

Is there any possibility to get only the parents which have at least x
children of type "child_type_2" with an specific value in an attribute.

e.g

parent_type: family
child_type_1: girl attribute:name
child_type_2: boy attribute:name
child_type_3: cat attribute:name

And i want to have all families which have at least three girls with name
"Jane".

Thank you for your help,
Alex

--
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:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/6622897e-3e72-4db4-b4a0-4d8555c077e8%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6ca23c8a-631b-4d3c-879e-69bb389eef06%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sorry for responding so late... something like this is possible:

By using score_type=max and wrapping the inner query in a constant_score query, the score represents the number of child docs that match with a
parent. Then by using the min_score feature you can filter out parent
hits that have less then X child doc matches.

On 7 January 2014 11:21, Alexander Stautner alexander.stautner@gmail.comwrote:

Changing the parent doc should be prevented, because there may be new
child_types added or old child_types may be removed and we want the
child_types be independed from the parent_type.

So it seems, that there is at the moment no way for doing suchs queries
with elasticsearch?

Thanks for helping.

Am Dienstag, 7. Januar 2014 10:39:41 UTC+1 schrieb David Pilato:

I would probably add a num_of_children field in parent doc and update it
when a new child is added or removed.

But I guess it depends on your actual use case!

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

Le 7 janv. 2014 à 08:15, Alexander Stautner alexander...@gmail.com a
écrit :

Sorry for bumping, but i need an answer, if it's posible to answer the
question above with elasticsearch

Am Donnerstag, 2. Januar 2014 15:22:32 UTC+1 schrieb Alexander Stautner:

Hello,
after some research without any results I have a question about
parent/child relations.

The case:

I have a parent of type "parent_type" which has children of different
types e.g. "child_type_1", "child_type_2", "child_type_3".

My Question is:

Is there any possibility to get only the parents which have at least x
children of type "child_type_2" with an specific value in an attribute.

e.g

parent_type: family
child_type_1: girl attribute:name
child_type_2: boy attribute:name
child_type_3: cat attribute:name

And i want to have all families which have at least three girls with
name "Jane".

Thank you for your help,
Alex

--
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.

To view this discussion on the web visit https://groups.google.com/d/
msgid/elasticsearch/6622897e-3e72-4db4-b4a0-4d8555c077e8%
40googlegroups.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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/6ca23c8a-631b-4d3c-879e-69bb389eef06%40googlegroups.com
.

For more options, visit https://groups.google.com/groups/opt_out.

--
Met vriendelijke groet,

Martijn van Groningen

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CA%2BA76Tye%3DheeEHfWhFjvty%3DMeRfy0oMxd9V0nSQvF%2BbUE-JiDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Awesome!

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

Le 19 janv. 2014 à 23:29, Martijn v Groningen martijn.v.groningen@gmail.com a écrit :

Sorry for responding so late... something like this is possible: example.sh · GitHub

By using score_type=max and wrapping the inner query in a constant_score query, the score represents the number of child docs that match with a parent. Then by using the min_score feature you can filter out parent hits that have less then X child doc matches.

On 7 January 2014 11:21, Alexander Stautner alexander.stautner@gmail.com wrote:
Changing the parent doc should be prevented, because there may be new child_types added or old child_types may be removed and we want the child_types be independed from the parent_type.

So it seems, that there is at the moment no way for doing suchs queries with elasticsearch?

Thanks for helping.

Am Dienstag, 7. Januar 2014 10:39:41 UTC+1 schrieb David Pilato:

I would probably add a num_of_children field in parent doc and update it when a new child is added or removed.

But I guess it depends on your actual use case!

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

Le 7 janv. 2014 à 08:15, Alexander Stautner alexander...@gmail.com a écrit :

Sorry for bumping, but i need an answer, if it's posible to answer the question above with elasticsearch

Am Donnerstag, 2. Januar 2014 15:22:32 UTC+1 schrieb Alexander Stautner:

Hello,
after some research without any results I have a question about parent/child relations.

The case:

I have a parent of type "parent_type" which has children of different types e.g. "child_type_1", "child_type_2", "child_type_3".

My Question is:

Is there any possibility to get only the parents which have at least x children of type "child_type_2" with an specific value in an attribute.

e.g

parent_type: family
child_type_1: girl attribute:name
child_type_2: boy attribute:name
child_type_3: cat attribute:name

And i want to have all families which have at least three girls with name "Jane".

Thank you for your help,
Alex

--
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.

To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6622897e-3e72-4db4-b4a0-4d8555c077e8%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/6ca23c8a-631b-4d3c-879e-69bb389eef06%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
Met vriendelijke groet,

Martijn van Groningen

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CA%2BA76Tye%3DheeEHfWhFjvty%3DMeRfy0oMxd9V0nSQvF%2BbUE-JiDQ%40mail.gmail.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/A810B812-FD31-48B0-905A-AF67B9711969%40pilato.fr.
For more options, visit https://groups.google.com/groups/opt_out.