2016-09-06 8 views
0

私は各エクステンションの合計を探しています。 JSONファイルが含まれていElasticSearch各エクステンションのクエリは、その長さの合計を取得

出力が

キーたかっ

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

サンプルコード:Jpegか10000000 キー:DOCX 20000000

しようとしたコード

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

出力

"キー":500000、 "doc_count":15

+0

http://stackoverflow.com/questions/39354830/trying-to-upload-json-files-コマンドラインエラーメッセージのために - elasticsearchを使用して – Nicola

答えて

0

これを試してみてください代わりに

GET /crud_sample2/Customer_Info/_search 
{ 
    "aggs": { 
    "sum": { 
     "terms": { 
     "field": "extension", 
     "order": {"total_length": "desc"} 
     }, 
     "aggs": { 
     "total_length": { 
      "sum": { 
      "field": "length" 
      } 
     } 
     } 
    } 
    } 
} 
+0

ありがとう非常にありがとうございます。 – Nicola

+0

は、あなたが「ソート」のようにそれを並べ替えることができますとにかくあります:{ 「total_length」:「DESC」 }、 「サイズ」:完璧な10 } – Nicola

+0

、感謝 – Nicola

関連する問題