# Top hits per type of each day

**URL:** <https://discuss.elastic.co/t/top-hits-per-type-of-each-day/206299>\
**Category:** Kibana\
**Created:** [November 3, 2019, 6:50pm UTC](https://discuss.elastic.co/t/top-hits-per-type-of-each-day/206299 "2019-11-03T18:50:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahul\_saini](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_saini/32/56969_2.png) [@rahul\_saini](https://discuss.elastic.co/u/rahul_saini)\
**Post date:** [November 3, 2019, 6:50pm UTC](https://discuss.elastic.co/t/top-hits-per-type-of-each-day/206299/1 "2019-11-03T18:50:06Z")

</div>

Hello,

I've an application with two modules - frontend & backend.

Both are getting scanned for defects multiple times a day.

We're collecting these results and pushing them over Elasticsearch, so we can see the defects trend.

I want to project this trend in Kibana visualization in daily basis, possibly in a line graph.

Thing is I must not take data of every scan as each module is getting scanned more than once in a day and taking sum of scan1 and scan2 will give wrong result.

So, I want to take top hit of each module, then take sum of both modules and show in a single line graph.

In other words, "Sum of top hits of both modules"

I'm very new in Kibana and not able to fully understand [top hits aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html).

So kindly suggest how can I make this visualization?

Thanks

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [November 8, 2019, 1:38pm UTC](https://discuss.elastic.co/t/top-hits-per-type-of-each-day/206299/2 "2019-11-08T13:38:11Z")

</div>

In Visualize, start by configuring a `Buckets` `Split series` to split your data by type.

 ![42%20AM](https://us1.discourse-cdn.com/elastic/original/3X/2/5/25723b263f18cfc990cd5ca29015e8980f9747be.png)

Then configure `Metric` to use a top hit aggregation. Other aggregations will calculate the metric value from all documents in a bucket. The top hits aggregation will only calculate the metric value from the first X documents in each bucket. In the example provided, the top hit will be the most recent document for each term `machine.os.keyword` ordered by field `timestamp`

 ![12%20AM](https://us1.discourse-cdn.com/elastic/original/3X/2/7/275fdf1cae4186df473d4ec475ac7f898d0084e1.png)

---

<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 6, 2019, 1:38pm UTC](https://discuss.elastic.co/t/top-hits-per-type-of-each-day/206299/3 "2019-12-06T13:38:11Z")

</div>

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