Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/55.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 深度量的弹性搜索导数_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Parent Child_Aggregation - Fatal编程技术网 elasticsearch 深度量的弹性搜索导数,elasticsearch,parent-child,aggregation,elasticsearch,Parent Child,Aggregation" /> elasticsearch 深度量的弹性搜索导数,elasticsearch,parent-child,aggregation,elasticsearch,Parent Child,Aggregation" />

elasticsearch 深度量的弹性搜索导数

elasticsearch 深度量的弹性搜索导数,elasticsearch,parent-child,aggregation,elasticsearch,Parent Child,Aggregation,我有一个网络爬虫,每天收集数据和存储快照数次。我的查询有一些聚合,它们每天将快照组合在一起,并使用top\u hits返回每天的最后一个快照 文档如下所示: "_source": { "taken_at": "2016-02-01T11:27:09.184-03:00", ... , "my_metric": 113 } 我希望能够计算某个指标的导数,例如my\u metric,由top\u hits返回的文档的导数(即每天my\u metric的最后快照的导数) 以下是我目前掌握

我有一个网络爬虫,每天收集数据和存储快照数次。我的查询有一些聚合,它们每天将快照组合在一起,并使用
top\u hits
返回每天的最后一个快照

文档如下所示:

"_source": {
  "taken_at": "2016-02-01T11:27:09.184-03:00",
  ... ,
  "my_metric": 113
}
我希望能够计算某个指标的导数,例如
my\u metric
,由
top\u hits
返回的文档的导数(即每天
my\u metric
的最后快照的导数)

以下是我目前掌握的情况:

{
  "aggs": {
    "filtered_snapshots": {
      "filter": {
        // ...
      },
      "aggs" : {
        "grouped_data": {
          "date_histogram": {
            "field": "taken_at",
            "interval": "day",
            "format": "YYYY-MM-dd",
            "order": { "_key" : "asc" }
          },
          "aggs": {
            "resource_by_date": {
              "terms": { "field": "remote_id" },
              "aggs": {
                "latest_snapshots": {
                  "top_hits": { 
                    "sort": { "taken_at": { "order": "asc" }},
                    "size" : 1
                  }
                }
              }
            },
            "my_metric_deriv": {
              "derivative": {
                "buckets_path": "resource_by_date>latest_snapshots>my_metric" 
              }
            }
          }
        }
      }
    }
  }
}
我在上面的查询中遇到“找不到路径的聚合[my_metric]”错误

我是否使用了错误的路径?我已经通读了文档和文档,没有发现有什么可以帮助我的


文档中简要地提到了“”,指出它们可以在某些方面受到限制,我不太理解。我不确定这些限制如何或是否会影响我的案例。

在您的
bucket\u路径中,
我的\u度量
指的是您文档的一个字段,这是不允许的。bucket路径只能包含由聚合及其子聚合组成的路径,直至子聚合字段(如总和、最大值等),但您不能访问由
top\u hits
聚合返回的文档中的字段。另外,您的
top\u hits
子聚合名为latest\u snapshot,但是您要的是最老的,也就是说,在
日期拍摄的最老的
。这是有意的吗?