# Kibana search sorting by count

**URL:** <https://discuss.elastic.co/t/kibana-search-sorting-by-count/188252>\
**Category:** Kibana\
**Created:** [July 1, 2019, 7:39am UTC](https://discuss.elastic.co/t/kibana-search-sorting-by-count/188252 "2019-07-01T07:39:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rishabhdeep\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rishabhdeep_singh/32/47247_2.png) [@Rishabhdeep\_Singh](https://discuss.elastic.co/u/Rishabhdeep_Singh)\
**Post date:** [July 1, 2019, 7:39am UTC](https://discuss.elastic.co/t/kibana-search-sorting-by-count/188252/1 "2019-07-01T07:39:58Z")

</div>

How do i Sort my search results by number of keywords present in the results.  
How do i do this in the discover and query?

---

<div class="post-metadata">

**Author:** ![Larry\_Gregory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/larry_gregory/32/34969_2.png) [@Larry\_Gregory](https://discuss.elastic.co/u/Larry_Gregory)\
**Post date:** [July 1, 2019, 1:31pm UTC](https://discuss.elastic.co/t/kibana-search-sorting-by-count/188252/2 "2019-07-01T13:31:55Z")

</div>

Hey @Rishabhdeep_Singh,

This is a fairly general question, but you can look into defining a [function score](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html) achieve this. Once your results are scored, you can sort on the `_score` field to get the results in the proper order.

---

<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:** [July 29, 2019, 1:32pm UTC](https://discuss.elastic.co/t/kibana-search-sorting-by-count/188252/3 "2019-07-29T13:32:01Z")

</div>

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