elasticsearch-head 查询按某字段去重后命中数量

代码

//需要在地址栏指明: http://ip:port/索引/_search   并使用post方法
{
  "query": {
    "match": {
      "facedbId": "xxx"  //指定facedbId='xxx'查询条件
    }
  },
  "size": 0,
  "aggs": {
    "labelId_aggs": {
      "cardinality": {
        "field": "labelId"  //指定查询结果按label_id去重
      }
    }
  }
}

结果 

elasticsearch-head 查询按某字段去重后命中数量_第1张图片

{
  "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  //粗略的去重后的命中数
    }
  }
}

 

你可能感兴趣的:(Elasticsearch)