GET gltrans/_search?size=0
{
"aggs": {
"code": {
"terms": {
"field": "code.keyword"
},
"aggs": {
"total": {
"sum": {
"field": "tot"
}
}
}
}
}
}
返回
"buckets" : [
{
"key" : "0220",
"doc_count" : 30182,
"total" : {
"value" : 169779.83551708516
}
},
{
"key" : "3000",
"doc_count" : 20360,
"total" : {
"value" : -477618.27972452715
}
},................
巢状查询
var result = _connectionToEs.EsClient().Search<gltrans>(s => s.Size(0)
.Aggregations(a => a
.Terms("code", st => st
.Field(o => o.code.Suffix("keyword"))
.Size(10)
.Aggregations(aa => aa
.Sum("total", m => m
.Field(o => o.tot))))));
没有“钥匙”的返回如何获得钥匙?
"Items": [
{
"tot": {
"Value": 169779.83551708516,
"ValueAsString": null,
"Meta": null
}
},
{
"tot": {
"Value": -477618.27972452715,
"ValueAsString": null,
"Meta": null
}
},
kibana开发工具GET gltrans / _search?size = 0 {{“ ggs”:{“ code”:{“ terms”:{“ field”:“ code.keyword”},“ aggs”:{“ total”: {“ sum”:{“ ...