1

我的索引由像这样的文件组成

{
"clientPorttopKByCount": [
            {
                "value": 1,
                "key": "41770"
            },
            {
                "value": 1,
                "key": "41791"
            }
],
"timestamp": 1574335260000,
}

要求:按 clientPorttopKByCount.key 分组,每 60 秒直方图求和 clientPorttopKByCount.value

我当前的 ES 查询:(它给出了错误的总和)

"aggregations": {
"clientPorttopKByCount.key": {
  "nested": {
    "path": "clientPorttopKByCount"
  },
  "aggregations": {
    "orders": {
      "terms": {
        "field": "clientPorttopKByCount.key",
        "size": 5000,
        "min_doc_count": 1,
        "shard_min_doc_count": 0,
        "show_term_doc_count_error": false,
        "order": [
          {
            "_count": "desc"
          },
          {
            "_key": "asc"
          }
        ]
      },
      "aggregations": {
        "records": {
          "reverse_nested": {

          },
          "aggregations": {
            "histogram": {
              "histogram": {
                "field": "timestamp",
                "interval": 60000.0,
                "offset": 0.0,
                "order": {
                  "_key": "asc"
                },
                "keyed": false,
                "min_doc_count": 0
              },
              "aggregations": {
                "clientPorttopKByCount.key": {
                  "nested": {
                    "path": "clientPorttopKByCount"
                  },
                  "aggregations": {
                    "clientPorttopKByCount.value_sum": {
                      "sum": {
                        "field": "clientPorttopKByCount.value"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
}

问题:它给出了单个键的所有直方图分钟的总和。

请帮我解决这个问题。

4

0 回答 0