Kibana Sort order

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

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

In the query bar add:

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

On the left hand side add the score field:

With the added column click on sort by score:

1 Like

Excellent :slight_smile: 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.

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.

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

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.

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 .

Thanks in advance ,
Raj

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