代码
//需要在地址栏指明: http://ip:port/索引/_search 并使用post方法
{
"query": {
"match": {
"facedbId": "xxx" //指定facedbId='xxx'查询条件
}
},
"size": 0,
"aggs": {
"labelId_aggs": {
"cardinality": {
"field": "labelId" //指定查询结果按label_id去重
}
}
}
}
结果
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 10000,
"relation": "gte"
},
"max_score": null,
"hits": []
},
"aggregations": {
"labelId_aggs": {
"value": 1130382 //粗略的去重后的命中数
}
}
}