GET test/_search
{
"size": 6,
"query": {
"bool": {
"must": [
{
"match": {
"title": "最好"
}
},
{
"exists": {
"field": "author"
}
}
],
"must_not": [
{
"match": {
"title": "广场"
}
},
{
"match": {
"author": ""
}
}
]
}
},
"_source": [
"title",
"author",
"cid",
"ctype"
],
"aggs": {
"最小": {
"min": {
"field": "cid"
}
},
"最大": {
"max": {
"field": "cid"
}
},
"平均值": {
"avg": {
"field": "cid"
}
},
"求和": {
"sum": {
"field": "cid"
}
},
"去重count": {
"cardinality": {
"field": "ctype"
}
},
"分组去重": {
"terms": {
"field": "ctype",
"size": 10
},
"aggs": {
"组内去重": {
"cardinality": {
"field": "ctype"
}
},
"组内求和": {
"sum": {
"field": "cid"
}
}
}
}
}
}
结果
{
"took": 5,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 3.9180572,
"hits": [
{
"_index": "huantv",
"_type": "index_metadata",
"_id": "0_96016",
"_score": 3.9180572,
"_source": {
"ctype": 0,
"author": "李婷",
"title": "重庆最贵的小面,2两28元一碗!一大块牛肉炖的酥烂!",
"cid": 96016
}
},
{
"_index": "huantv",
"_type": "index_metadata",
"_id": "0_95961",
"_score": 3.7654238,
"_source": {
"ctype": 0,
"author": "何三岁",
"title": "内蒙最火的小吃!稍麦大坨肉面皮比纱还薄,羊油煎后美味升级!",
"cid": 95961
}
}
]
},
"aggregations": {
"去重count": {
"value": 1
},
"最小": {
"value": 95961
},
"平均值": {
"value": 95988.5
},
"求和": {
"value": 191977
},
"最大": {
"value": 96016
},
"分组去重": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 0,
"doc_count": 2,
"组内求和": {
"value": 191977
},
"组内去重": {
"value": 1
}
}
]
}
}
}