ElasticSearch Aggs查询

时间:2016-03-23 16:01:06

标签: elasticsearch

我有以下弹性搜索查询和结果。我希望在sql语句

中使用count by(*)= 1之类的东西
{
"size": 0,
  "aggs": {
    "group_by_RequestID": {
      "terms": {
        "field": "RequestID"
      } 
    }
  }
}


{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 12,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "group_by_RequestID": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": "20160209 132857.249_5420_1_ATL",
          "doc_count": 2
        },
        {
          "key": "20160209 132857.249_5420_1_DEN1100",
          "doc_count": 2
        },
        {
          "key": "20160209 132857.249_5420_1_LAS",
          "doc_count": 2
        },
        {
          "key": "20160209 132857.249_5420_1_PHX1300",
          "doc_count": 2
        },
        {
          "key": "20160209 132857.249_5420_1_PHX1400",
          "doc_count": 2
        },
        {
          "key": "20160209 132857.249_5420_1_SFO",
          "doc_count": 2
        }
      ]
    }
  }
}

我希望我的结果回到" doc_count" = 1  你能指导我怎样才能得到那个结果?

由于

1 个答案:

答案 0 :(得分:0)

您应该使用Bucket selector aggregation _count字段获得所需的结果special