You can get the 20 biggest values of a number by sorting the Terms aggregation in Descending Alphabetical order, but not in ascending order- that will get you the 20 smallest values because it's doing sorting inside Elasticsearch. It is possible to use column sorting in the Data Table visualization, which takes the results from Elasticsearch and re-sorts them.
That's right, the order of the data is what controls the order of the visualization for other chart types. Yesterday I opened an issue to track this as a feature request for Lens, which would also solve your use case. It also includes links to past requests: https://github.com/elastic/kibana/issues/86184
We do offer a fully custom visualization builder, you can follow my Vega tutorial to learn about how it works.
I don't think I understand your second question about "latest value in a bucket". You would need to be more specific about what your input data is and what you want the output data to be. I suggest that you open a new thread to explain your question more.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.