elasticsearch怎么同时对类型的多个字段根据条件进行聚合?
比如
a类型:
[{"name":"zhangsan","age":12},{"name":"zhangsan","age":12},{"name":"lisi","age":13},{"name":"lisi","age":13}]
希望得到的聚类结果如下:
"aggregations" : {
"name" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ {
"key" : "zhangsan",
"doc_count" : 2
}, {
"key" : "lisi",
"doc_count" : 2
} ]
},
"age" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ {
"key" : "12",
"doc_count" : 2
}, {
"key" : "13",
"doc_count" : 2
} ]
}
}
查询语句怎么写
比如
a类型:
[{"name":"zhangsan","age":12},{"name":"zhangsan","age":12},{"name":"lisi","age":13},{"name":"lisi","age":13}]
希望得到的聚类结果如下:
"aggregations" : {
"name" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ {
"key" : "zhangsan",
"doc_count" : 2
}, {
"key" : "lisi",
"doc_count" : 2
} ]
},
"age" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [ {
"key" : "12",
"doc_count" : 2
}, {
"key" : "13",
"doc_count" : 2
} ]
}
}
查询语句怎么写
0 个回复