我想在price
方面获得date range
字段(均值/中位数/标准差)的solr统计数据。这可能吗?例如:
....solr/collection1/select?q=description:iphone
&facet=true
&facet.range=timestamp
&facet.range.start=NOW/MONTH
&facet.range.end=NOW/MONTH%2B1MONTH
&facet.range.gap=%2B1DAY
&stats=true
&stats.field=price
给我结果:
{u'facet_ranges': {u'timestamp': {u'counts': [u'2017-06-01T00:00:00Z',
79,
u'2017-06-02T00:00:00Z',
237,
.... a bunch more stats for each day....
... a bunch of listings ....
u'stats': {u'stats_fields': {u'price': {u'count': 28861,
u'facets': {},
u'max': 4000.0,
u'mean': 161.44501277067423,
u'min': 0.07000000029802322,
u'missing': 2778,
u'stddev': 143.61418183614867,
u'sum': 4659464.513574429,
u'sumOfSquares': 1347485766.7566266}}}
}
但是我想看到白天细分的统计数据:
{u'facet_ranges': {u'timestamp': {u'2017-06-01T00:00:00Z':
{ "counts:79,
"mean: 17.72,
"median: 18,
"stdev": 3.7,
}
u'2017-06-02T00:00:00Z':
{ "counts:237,
"mean: 81.32,
"median: 88,
"stdev": 13.37,
....
答案 0 :(得分:1)
使用json facets:
{ prices:
{ type: range,
field: timestamp,
start: "NOW/MONTH",
end:"NOW/MONTH+1MONTH",
gap: "+1DAY",
facet:{
x : "avg(price)",
y : "sum(price)"
}
}
}
要获得平均值,每桶的平均等值,请查看您可以使用的Aggregate rangfunctions