简体   繁体   中英

SOLR date hourly average

does it possible to query hourly average statistics ( count ) by date field?

now best what I can is facet it and calculate on client side

facet.range.gap=%2B1HOUR
&facet.range.start=2016-03-01T00:00:00Z
&facet.range.end=2016-03-08T00:00:00Z
&facet.range=date_field

maybe there is a way to calculate it by single query?

json.facet: "{
    "hourly_buckets":{
         "type":"range",
         "field":"date_field",
         "start":"2016-03-01T00:00:00Z",
         "end":"2016-03-08T00:00:00Z",
         "gap":"+1HOUR",
         "facet": {
             "average_field_value":"avg(field_name_to_get_average_for)"
         }        
    }
}"

see this link on solr facet functions for more: http://yonik.com/solr-facet-functions/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM