# Difference between top hit and max in kibana visualization aggregation

**URL:** <https://discuss.elastic.co/t/difference-between-top-hit-and-max-in-kibana-visualization-aggregation/265309>\
**Category:** Kibana\
**Created:** [February 24, 2021, 9:44am UTC](https://discuss.elastic.co/t/difference-between-top-hit-and-max-in-kibana-visualization-aggregation/265309 "2021-02-24T09:44:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)\
**Post date:** [February 24, 2021, 9:44am UTC](https://discuss.elastic.co/t/difference-between-top-hit-and-max-in-kibana-visualization-aggregation/265309/1 "2021-02-24T09:44:28Z")

</div>

Hi all,

I am trying to find the difference between top hit aggregation and max aggregation in kibana.

They both are supposed to give maximum value of a group.

I went through threads, but could not find anything related to this.

Regards

---

<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:** [February 24, 2021, 3:00pm UTC](https://discuss.elastic.co/t/difference-between-top-hit-and-max-in-kibana-visualization-aggregation/265309/2 "2021-02-24T15:00:04Z")

</div>

There is a way to get the same value from Top Hits, but it does more than that. It's most frequent usage in Kibana is to sort by the time field, and then get the "last value" within each bucket. For example, to get the most recent keyword per unique term.

> **[Top hits aggregation | Elasticsearch Reference \[7.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html)**

---

<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:** [March 24, 2021, 3:00pm UTC](https://discuss.elastic.co/t/difference-between-top-hit-and-max-in-kibana-visualization-aggregation/265309/3 "2021-03-24T15:00:38Z")

</div>

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