Getting statistics for each bucket in the facet result


(jdd) #1

Hi,
I have a document with two fields, timestamp (date) and response_time
(numeric).
Now suppose I want to do a query like 'Get the daily average response time
for each day of the last 10 days', what's the recommended way to do this?
If I want to use the Statistical facet, then I will have to fire the same
query (changing date range in the filter each time) 10 times. Is there a
way this could be done in a single query?

Basically I want to do a date range facet on the timestamp field, and for
each daily bucket I want to calculate the statistical function (like mean,
max, distinct etc)

Thanks,
Jaideep


(Ivan Brusic) #2

A Date Histogram Facet with the Value Field set is probably what you
are looking for:

http://www.elasticsearch.org/guide/reference/api/search/facets/date-histogram-facet.html

Cheers,

Ivan

On Fri, Aug 3, 2012 at 1:57 AM, jdd jaideep.dhok@gmail.com wrote:

Hi,
I have a document with two fields, timestamp (date) and response_time
(numeric).
Now suppose I want to do a query like 'Get the daily average response time
for each day of the last 10 days', what's the recommended way to do this?
If I want to use the Statistical facet, then I will have to fire the same
query (changing date range in the filter each time) 10 times. Is there a way
this could be done in a single query?

Basically I want to do a date range facet on the timestamp field, and for
each daily bucket I want to calculate the statistical function (like mean,
max, distinct etc)

Thanks,
Jaideep


(jdd) #3

That helps. Thanks,

Jaideep

On Friday, 3 August 2012 22:21:05 UTC+5:30, Ivan Brusic wrote:

A Date Histogram Facet with the Value Field set is probably what you
are looking for:

http://www.elasticsearch.org/guide/reference/api/search/facets/date-histogram-facet.html

Cheers,

Ivan

On Fri, Aug 3, 2012 at 1:57 AM, jdd jaideep.dhok@gmail.com wrote:

Hi,
I have a document with two fields, timestamp (date) and response_time
(numeric).
Now suppose I want to do a query like 'Get the daily average response
time
for each day of the last 10 days', what's the recommended way to do
this?
If I want to use the Statistical facet, then I will have to fire the
same
query (changing date range in the filter each time) 10 times. Is there a
way
this could be done in a single query?

Basically I want to do a date range facet on the timestamp field, and
for
each daily bucket I want to calculate the statistical function (like
mean,
max, distinct etc)

Thanks,
Jaideep


(system) #4