Build Histogram/Percentile based on count from another field


(Sundar V) #1

Hello,

A sample set of documents that we store are

{"name": "GET /login", "avg":"2.2", "count": 5}
{"name": "GET /login", "avg":"1.5", "count": 3}
{"name": "GET /login", "avg":"6.9", "count": 1}
{"name": "GET /login", "avg":"3.1", "count": 1}

When I run histogram for GET /login alone, with interval of 1 second I get

1-2 seconds - 1
2-3 seconds - 1
3-4 seconds - 1
5-6 seconds - 1

However, what we are doing is, we are only storing the average with the count (to save space and not duplicate the records). But in reality, what we would like to get is

1-2 seconds - 3
2-3 seconds - 5
3-4 seconds - 1
5-6 seconds - 1

The same problem appears for percentile as well.

1.5, 2.2, 3.1, 6.9 - The 75th percentile is reported as 3.1 second.
1.5, 1.5, 1.5, 2.2, 2.2, 2.2, 2.2, 2.2, 3.1, 6.9 - The real 75th percentile is 2.2 seconds

Is that possible with elastic search?

Sundar.


(system) #2