# Count Of Metric after Doing Top Hits

**URL:** <https://discuss.elastic.co/t/count-of-metric-after-doing-top-hits/169292>\
**Category:** Kibana\
**Created:** [February 20, 2019, 9:19pm UTC](https://discuss.elastic.co/t/count-of-metric-after-doing-top-hits/169292 "2019-02-20T21:19:43Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [February 21, 2019, 9:52pm UTC](https://discuss.elastic.co/t/count-of-metric-after-doing-top-hits/169292/2 "2019-02-21T21:52:12Z")

</div>

The most straightforward and scalable way would be to have an index of data modeled separately. Here, instead of an index of raw events, having a caseId centric index would make this an easy aggregation.

The caseId index would use `case_id` as the \_id for the ES docs. When events come in, update the case document by ID and it will have the latest status.

The table then becomes an aggregation of each status keyword, and the count of documents in the case index that have that status.

---

_[View the full topic](https://discuss.elastic.co/t/count-of-metric-after-doing-top-hits/169292)._
