Hi everyone,
I'm looking for the best way to calculate percentages when working with aggregated data in Elasticsearch.
For example, suppose an index contains 10,000 documents, and 1,500 of them belong to a particular category. I want to calculate what percentage of all documents belongs to that category.
The basic formula is:
Percentage = (Category Document Count / Total Document Count) × 100
In this example, the result would be 15%.
I understand that Elasticsearch aggregations can group documents and return document counts, but I'm interested in the best approach for calculating and displaying the percentage, especially when working with multiple categories in Kibana.
Would a bucket script aggregation be suitable, or would it be better to calculate the percentage in the application or visualization layer?
Thanks in advance for any suggestions!