Here's my code to get inner hits count.
GET my_index/_search
{
"_source": [
"inner_hits"
],
"query": {
"nested": {
"path": "someNestedKey",
"query": {
"bool": {
"must": [
{
"exists": {
"field": "someNestedKey.key1"
}
}
]
}
},
"inner_hits": {}
}
}
}
This gives me the following response.
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "my_index",
"_type" : "_doc",
"_id" : "someid",
"_score" : 1.0,
"_source" : { },
"inner_hits" : {
"my_nested_field" : {
"hits" : {
"total" : {
**"value" : 5,**
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [{Removed the data}
]
}
}
}
},
{
"_index" : "my_index",
"_type" : "_doc",
"_id" : "someid",
"_score" : 1.0,
"_source" : { },
"inner_hits" : {
"my_nested_field" : {
"hits" : {
"total" : {
**"value" : 4,**
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{Removed the data}
]
}
}
}
}
]
}
}
If you check the bold highlighted part, I basically need to get the total count that is 5+4 = 9 and show it inside Kibana's metric visualisation. I am not quite sure how to do it?