# Sort Results in Discovery Kibana (KQL)

**URL:** <https://discuss.elastic.co/t/sort-results-in-discovery-kibana-kql/252151>\
**Category:** Kibana\
**Created:** [October 15, 2020, 8:08am UTC](https://discuss.elastic.co/t/sort-results-in-discovery-kibana-kql/252151 "2020-10-15T08:08:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesus\_Moyano\_Dona](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jesus_moyano_dona/32/77241_2.png) [@Jesus\_Moyano\_Dona](https://discuss.elastic.co/u/Jesus_Moyano_Dona)\
**Post date:** [October 15, 2020, 8:08am UTC](https://discuss.elastic.co/t/sort-results-in-discovery-kibana-kql/252151/1 "2020-10-15T08:08:46Z")

</div>

Hello, I have a database about flights and I want to create a coordinate map, so I need the last entry of each flight.

I'm new to Elastic and Kibana, I don't know about how to do it.

In this example, I filtered by the ICAO, and I got 5 entries. I want to sort by date and get the last one, so I will have a new discover list without repeated ICAOs, only with the last one.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/1/814974f1701a9b261f24ba6b22124054c3bbfa43.png)

---

<div class="post-metadata">

**Author:** ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)\
**Post date:** [October 15, 2020, 9:15pm UTC](https://discuss.elastic.co/t/sort-results-in-discovery-kibana-kql/252151/2 "2020-10-15T21:15:04Z")

</div>

hi @Jesus_Moyano_Dona

So you're not able to do this filtering in Discover, and you would not be able to create this map in the Coordinate map visualization.

Your use-case _is_ supported by the Maps-application.

What you need is top-hits (showing _last_ location per icao). This is supported by the Maps-app.

Details see here: [https://www.elastic.co/guide/en/kibana/current/maps-top-hits-aggregation.html](https://www.elastic.co/guide/en/kibana/current/maps-top-hits-aggregation.html)

In the Maps-app, click "Add layer", choose "Documents". Then choose "show top hits by entity", and then select `1` for size. Make sure to order-descending by time in the "Sort" card.

It'd look something like:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/5/55934a8d27edabaa62ce96bb8dd12497a5cc450d.png)

Imagine "host.keyword" is "icao" in your example.

Also, make sure the `positiongeohash` field is actually indexed as `geo_point` into elasticsearch. [https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.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:** [November 12, 2020, 9:15pm UTC](https://discuss.elastic.co/t/sort-results-in-discovery-kibana-kql/252151/3 "2020-11-12T21:15:14Z")

</div>

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