# Kibana Sort order

**URL:** <https://discuss.elastic.co/t/kibana-sort-order/90936>\
**Category:** Kibana\
**Created:** [June 27, 2017, 9:23am UTC](https://discuss.elastic.co/t/kibana-sort-order/90936 "2017-06-27T09:23:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raj\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raj_kumar/32/25420_2.png) [@Raj\_Kumar](https://discuss.elastic.co/u/Raj_Kumar)\
**Post date:** [June 27, 2017, 9:23am UTC](https://discuss.elastic.co/t/kibana-sort-order/90936/1 "2017-06-27T09:23:17Z")

</div>

Hi All,

Is there any way i could get random sort order instead of ascending or descending , i need random datas not based on counts.

Please let me know if there is any way to get it.That could really useful for random auditing.

Thanks,  
Raj

---

<div class="post-metadata">

**Author:** ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)\
**Post date:** [June 27, 2017, 4:15pm UTC](https://discuss.elastic.co/t/kibana-sort-order/90936/2 "2017-06-27T16:15:35Z")

</div>

On the discover page? You can do this with random scoring.

In the query bar add:

```auto
{
  "function_score": {
    "query": {
      "match_all": {}
    },
    "functions": [
      {
        "random_score": {}
      }
    ]
  }
}

```

On the left hand side add the score field:  
 ![](https://us1.discourse-cdn.com/elastic/original/3X/6/a/6ad108fc528adeea7879ec804b7d4dcad9b99b0b.png)

With the added column click on sort by score:  
 ![](https://us1.discourse-cdn.com/elastic/original/3X/9/9/996e2c46cf86bc3f0fd9e3a373881aa530401124.png)

---

<div class="post-metadata">

**Author:** ![Raj\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raj_kumar/32/25420_2.png) [@Raj\_Kumar](https://discuss.elastic.co/u/Raj_Kumar)\
**Post date:** [June 27, 2017, 6:08pm UTC](https://discuss.elastic.co/t/kibana-sort-order/90936/3 "2017-06-27T18:08:59Z")

</div>

Excellent 🙂 Thank you so much, can I use this saved search, to create visualisation for example if am creating datatable can it sort it random as well instead of counts.

---

<div class="post-metadata">

**Author:** ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)\
**Post date:** [June 27, 2017, 7:40pm UTC](https://discuss.elastic.co/t/kibana-sort-order/90936/4 "2017-06-27T19:40:36Z")

</div>

There may be a creative way to do it but I can't think of anything offhand. Kibana support for scripted metric aggregations would make this possible but it hasn't been implemented as of yet, ref [https://github.com/elastic/kibana/issues/2646](https://github.com/elastic/kibana/issues/2646).

---

<div class="post-metadata">

**Author:** ![Raj\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raj_kumar/32/25420_2.png) [@Raj\_Kumar](https://discuss.elastic.co/u/Raj_Kumar)\
**Post date:** [June 27, 2017, 7:52pm UTC](https://discuss.elastic.co/t/kibana-sort-order/90936/5 "2017-06-27T19:52:44Z")

</div>

Thank you Jon ,for the time and reply that makes completely sense, if am using discover option alone and am selecting time frame of one month can i get documents of any random five documents instead of all the entire one month documents based on \_score sort

---

<div class="post-metadata">

**Author:** ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)\
**Post date:** [June 27, 2017, 8:18pm UTC](https://discuss.elastic.co/t/kibana-sort-order/90936/6 "2017-06-27T20:18:29Z")

</div>

When you add the index pattern in kibana, not selecting a time field is an option and will prevent queries from filtering by time. You can keep this side by side with your current index pattern if you cut off an extra character and use a wildcard.

---

<div class="post-metadata">

**Author:** ![Raj\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raj_kumar/32/25420_2.png) [@Raj\_Kumar](https://discuss.elastic.co/u/Raj_Kumar)\
**Post date:** [June 28, 2017, 12:43pm UTC](https://discuss.elastic.co/t/kibana-sort-order/90936/7 "2017-06-28T12:43:31Z")

</div>

Hi Jon,

Am really sorry if didnt get you correctly or if your very deep technical in your product

I have selected this month entire data and used ur random score query, if its possible to get

only the first five results alone .

 ![](https://us1.discourse-cdn.com/elastic/original/3X/c/8/c8db23d329be1c0746255e78dc85d2a8fe68415c.png)

Thanks in advance ,  
Raj

---

<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 26, 2017, 12:43pm UTC](https://discuss.elastic.co/t/kibana-sort-order/90936/8 "2017-07-26T12:43:36Z")

</div>

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