我们能有两个相同的水平聚合吗?例如,我希望在一个桶聚合中拥有两个不同字段的两个stats聚合。我怎么才能特别这么做呢?
发布于 2014-08-18 07:55:52
好的,我找到解决办法了
{
"size" : 0,
"query" : {
"filtered" : {
"query" : {
"match_all" : { }
},
"filter" : {
"and" : {
"filters" : [ {
"numeric_range" : {
"transactionDate" : {
"from" : "2013-08-01",
"to" : "2013-11-01",
"include_lower" : true,
"include_upper" : true
}
}
}]
}
}
}
},
"aggregations" : {
"monthWise1" : {
"date_range" : {
"field" : "transactionDate",
"ranges" : [ {
"key" : "Aug-2013",
"from" : "2013-08-01",
"to" : "2013-08-31"
}, {
"key" : "Sep-2013",
"from" : "2013-09-01",
"to" : "2013-09-30"
}, {
"key" : "Oct-2013",
"from" : "2013-10-01",
"to" : "2013-10-31"
} ]
},
"aggregations" : {
"statField1" : {
"stats": {
"field": "balance"
}
},
"statField2" : {
"stats": {
"field": "discount"
}
}
}
}
}
}https://stackoverflow.com/questions/25358116
复制相似问题