# Kibana metric visualization - Get Inner hits count

**URL:** <https://discuss.elastic.co/t/kibana-metric-visualization-get-inner-hits-count/255781>\
**Category:** Kibana\
**Created:** [November 18, 2020, 4:12am UTC](https://discuss.elastic.co/t/kibana-metric-visualization-get-inner-hits-count/255781 "2020-11-18T04:12:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhilash\_Sathe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhilash_sathe/32/28555_2.png) [@Abhilash\_Sathe](https://discuss.elastic.co/u/Abhilash_Sathe)\
**Post date:** [November 18, 2020, 4:12am UTC](https://discuss.elastic.co/t/kibana-metric-visualization-get-inner-hits-count/255781/1 "2020-11-18T04:12:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [November 19, 2020, 6:59pm UTC](https://discuss.elastic.co/t/kibana-metric-visualization-get-inner-hits-count/255781/2 "2020-11-19T18:59:53Z")

</div>

The metric visualization doesn't support nested data like this. You probably should use [Vega](https://www.elastic.co/guide/en/kibana/current/vega-lite-tutorial-create-your-first-visualizations.html) because that would let you run the query directly using the query DSL

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 17, 2020, 6:59pm UTC](https://discuss.elastic.co/t/kibana-metric-visualization-get-inner-hits-count/255781/3 "2020-12-17T18:59:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
