0

我正在寻找每个扩展的总和。json文件包含

示例代码

       {"index":{"_id":"202"}} 
        "length":500000
         "extension":".jpeg"

想要的输出

密钥:Jpeg 10000000 密钥:docx 20000000

试过的代码

        GET /crud_sample2/Customer_Info/_search?extension
          { 
          "aggs": {
          "sum": {
            "terms": {
              "field": "length"
              }
          }
           }
        } 

输出

“key”:500000,“doc_count”:15

4

1 回答 1

0

试试这个

GET /crud_sample2/Customer_Info/_search
{
  "aggs": {
    "sum": {
      "terms": {
        "field": "extension",
        "order": {"total_length": "desc"}
      },
      "aggs": {
        "total_length": {
          "sum": {
            "field": "length"
          }
        }
      }
    }
  }
}
于 2016-09-06T07:38:56.297 回答