Hello,
I would like to know, if there is a possibility to retrieve the inner hits in an optimized way?
Consider following example:
PUT my_index
{
"mappings": {
"my_parent": {},
"my_child": {
"_parent": {
"type": "my_parent"
}
}
}
}
PUT my_index/my_parent/1
{
"text": "This is a parent document"
}
PUT my_index/my_child/2?parent=1
{
"text": "This is a child document"
}
PUT my_index/my_child/3?parent=1&refresh=true
{
"text": "This is another child document"
}
PUT my_index/my_parent/11
{
"text": "This is a parent 11 document"
}
PUT my_index/my_child/12?parent=11
{
"text": "This is a child 12 document"
}
PUT my_index/my_child/13?parent=11&refresh=true
{
"text": "This is another child 13 document"
}
When I search for inner hits using following search, it will include the "parent" for each of its child. For smaller results this is not a problem, consider when we have several child documents and then for each child document the same parent document is copied in the results. Do we have any possibility to have a separate list of parents and the inner hits contain only its corresponding parent ID? This way much traffic can be saved.
POST my_index/my_child/_search
{
"query": {
"has_parent": {
"parent_type": "my_parent",
"query": {
"match": {
"text": "parent"
}
},
"inner_hits" : {
"name" : "abc"
}
}
}
}
Thanks,
Niaz