Return facets across matched children in a has_child search over parent?

Im running a _search request that uses combination of a simple term match
in the "sink" parent object and has_child query filter to get me all "sink"
parent objects with a certain myfield term value that have "source"
children that DONT have the same myfield term, e.g.:

curl -XPOST localhost:9200/test/sink/_search?pretty=true -d '{
"query": {
"filtered": {
"filter":{
"and": [
{ "term": {"myfield": "myfieldvalue1"} },
{ "has_child": {
"type": "source",
"query" : {
"filtered": {
"filter" : {
"not":
{"term": {"myfield": "myfieldvalue1"}}
}
}
}
}
}
]
}
}
},
...

This returns me the "sink" documents as desired, which is great.

Now I'd like to get facets back in this search for a different field in all
the "source" children that were matched. For example, if each "source"
child had a field "type" I'd like to get all the different types for
"sources" that were children to these matched "sink" objects.

I've read this
solution: https://github.com/elasticsearch/elasticsearch/issues/2606 but Im
unable to get something like this working.

I can probably write a second query to get me the facets by searching over
the "sources" and use "has_parent" (I think, still getting up to speed with
the search syntax and capabilities) but is there anything I can do with
this example above to get me those source "type" facets. In essence, a set
of facets for the children matching the parent's query.

Thanks
Jonathan

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

I'll just add that this is the "facet" query results I'd like to come back
with the above (its the same the above but run over the child objects, thus
the has_parent usage rather than has_child).. but without running this
secondary query to get it if possible.

curl -XPOST localhost:9200/everlink/source/_search -d '{

"query": {
"filtered": {
"filter":{
"and": [
{ "not": { "term": {"myfield": "myvalue"} } },
{ "has_parent": {
"type": "page",
"query" : {
"filtered": {
"filter" :
{"term": {"myfield": "myvalue"}}
}
}
}
}
]
}
}
},
"facets" : {
"types" : { "terms" : {"field" : "type"} }
},
"size":0
}'

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

I'll just add that this is the "facet" query results I'd like to come back
with the above (its the same the above but run over the child objects, thus
the has_parent usage rather than has_child).. but without running this
secondary query to get it if possible.

curl -XPOST localhost:9200/everlink/source/_search -d '{

"query": {
"filtered": {
"filter":{
"and": [
{ "not": { "term": {"myfield": "myvalue"} } },
{ "has_parent": {
"type": "sink",
"query" : {
"filtered": {
"filter" :
{"term": {"myfield": "myvalue"}}
}
}
}
}
]
}
}
},
"facets" : {
"types" : { "terms" : {"field" : "type"} }
},
"size":0
}'

--
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.
For more options, visit https://groups.google.com/groups/opt_out.