In some of our types, we have a parent setting for the parent, and we want to search in the parent fields, as well as in the child fields (and return the parent), and we make a request, as shown below. When there is a has_child match, there is a way to get the selection of information from the child match, even if the parent returns. As an example, if we have a mapping similar to the following:
PUT nested2
{
"mappings":{
"discussion":{
"properties" : {
"title":{
"type":"string"
}
}
},
"discussionPost":{
"_parent":{
"type" : "discussion"
},
"properties" : {
"post" : {
"type" : "string"
}
}
}
}
}
And we issue a request, as shown below, the highlight information is returned if there is a match in the parent field, but not if the parent is returned due to has_child matching:
POST nested2/discussion/_search
{
"query": {
"bool": {
"should": [
{
"prefix": {
"_all" : "cat"
}
},
{
"has_child" : {
"type" : "discussionPost",
"score_mode" : "sum",
"query" : {
"prefix": {
"_all" : "cat"
}
}
}
}
],
"minimum_should_match": 1
}
},
"highlight":{
"fields":{
"*":{}
}
}
}
Is it possible to get information about what corresponds to the child when the is_child request is issued on the parent?
LT relationship