【发布时间】:2019-01-23 03:22:30
【问题描述】:
我使用的是弹性搜索版本 6.0.0 对于按月分组,我使用日期直方图聚合。 我试过的例子:
{
"from":0,
"size":2000,
"_source":{
"includes":[
"cost",
"date"
],
"excludes":[
],
"aggregations":{
"date_hist_agg":{
"date_histogram":{
"field":"date",
"interval":"month",
"format":"M",
"order":{
"_key":"asc"
},
"min_doc_count":1
},
"aggregations":{
"cost":{
"sum":{
"field":"cost"
}
}
}
}
}
}
}
结果我多次获得 1(1 月/1 月)。 因为我有 2016 年 1 月、2017 年 1 月、2018 年 1 月的数据,所以会在一月返回 3 次。但我只想要一月一次,其中包含一月所有年份的总和。
【问题讨论】:
标签: elasticsearch elasticsearch-5 elasticsearch-aggregation elasticsearch-6