Possible to return matched children in a query with has_child?

I have 2 types, people and pet.

Each pet has a parent which is a people.

I am running a search to search on the people and pet names and to return
the people for matched people and pets.

This is the query I am using and it works great:
{
"query":{
"bool":{
"must":[
{
"term":{
"statuses":{
"value":"active",
"boost":1
}
}
}
],
"should":[
{
"match":{
"people.name":{
"type":"phrase_prefix",
"query":"john"
}
}
},
{
"has_child":{
"query":{
"prefix":{
"pet.name":{
"value":"john",
"boost":1
}
}
},
"type":"pet"
}
}
]
}
}
}

The problem is that if the match is a pet's name, I would like to also
return the pet that matched along with the results. Is there any way to do
this?

Currently, I am running the same query again, but only against pets, which
is grossly inefficient.

Cheers :slight_smile:

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