Reputation: 15156
If I have a child-parent mapping in elastic search. How would I go about searching for parents based on statistics of their children.
Example:
{
'parent':{
'_id':{
'path':'parent_id'
},
'properties':{
'parent_id':{
'type':'string'
},
'name':{
'type':'string'
},
'job':{
'type':'string'
},
'age':{
'type':'integer'
},
}
}
}{
'child':{
'_parent':{
'type':'parent'
},
'_id':{
'path':'child_id'
},
'properties':{
'child_id':{
'type':'string'
},
'name':{
'type':'string'
},
'favorite_toy':{
'type':'string'
},
'age':{
'type':'integer'
},
}
}
}
How would I:
Upvotes: 1
Views: 1278
Reputation: 30163
1) and 2) - you can simply wrap your query into has_child query:
{
"has_child":{
"type":"child",
"query":{
"match":{
"name":"bob"
}
}
}
}
3) and 4) - I don't think this is possible at the moment.
Upvotes: 3