每个扩展的 ElasticSearch 查询获取其长度的总和
ElasticSearch Query for each extension get the sum of its length
我正在寻找每个扩展的总和。
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
试试这个
GET /crud_sample2/Customer_Info/_search
{
"aggs": {
"sum": {
"terms": {
"field": "extension",
"order": {"total_length": "desc"}
},
"aggs": {
"total_length": {
"sum": {
"field": "length"
}
}
}
}
}
}
我正在寻找每个扩展的总和。 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
试试这个
GET /crud_sample2/Customer_Info/_search
{
"aggs": {
"sum": {
"terms": {
"field": "extension",
"order": {"total_length": "desc"}
},
"aggs": {
"total_length": {
"sum": {
"field": "length"
}
}
}
}
}
}