How can buckets be sorted by doc_count ratio?

I have data
{
"id": 1,
"buyer_id": 101,
"total_count": 2
}
{
"id": 2,
"buyer_id": 101,
"total_count": 2
}

{
"id": 3,
"buyer_id": 102,
"total_count": 1
}
After aggregation by buyer_id, I want to sort by "doc_count / total_count", is this possible? How does it work?

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script is something anyone can copy and paste in Kibana dev console, click on the run button to reproduce your use case. It will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

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