<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # Derivative Aggregation(導數聚合) 原文鏈接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-pipeline-derivative-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-pipeline-derivative-aggregation.html) 譯文鏈接 : [Derivative Aggregation(導數聚合)](/pages/viewpage.action?pageId=10030239) 貢獻者 : @蘇濤,[ApacheCN](/display/~apachecn),[Apache中文網](/display/~apachechina) 警告 此功能是實驗性的,可能會在將來的版本中完全更改或刪除。Elastic將采取最大的努力來解決此問題,但實驗功能不受SLA官方功能的支持。 導數管道聚合,其計算父直方圖(或日期 - 圖形)聚合中指定度量的導數。指定的度量必須是數字,并且必須設置直方圖min_doc_count為0(默認為直方圖聚合)。 ### 語法 `derivative(導數)`?聚合結構如下: ``` "derivative": { "buckets_path": "the_sum" } ``` `derivative(導數)`?參數如下: | 參數名稱 | 描述 | 是否必填 | 默認值 | | --- | --- | --- | --- | | buckets_path | 想要計算導數值的桶路徑,點擊?[the section called “`buckets_path`?Syntax](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-pipeline.html#buckets-path-syntax "buckets_path Syntaxedit")[edit](https://github.com/elastic/elasticsearch/edit/5.4/docs/reference/aggregations/pipeline.asciidoc "Edit this page on GitHub")”查看更多細節 | 必填 | ? | | gap_policy | 當數據缺口出現時采用的策略,點擊[the section called “Dealing with gaps in the data](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-pipeline.html#gap-policy "Dealing with gaps in the dataedit")[edit](https://github.com/elastic/elasticsearch/edit/5.4/docs/reference/aggregations/pipeline.asciidoc "Edit this page on GitHub")”查看更多細節 | 可選 | skip | | format | 用于規范聚合輸出值的格式 | 可選 | null | ### 一級導數 以下代碼段計算每月總銷售額的導數: ``` POST /sales/_search { "size": 0, "aggs" : { "sales_per_month" : { "date_histogram" : { "field" : "date", "interval" : "month" }, "aggs": { "sales": { "sum": { "field": "price" } }, "sales_deriv": { "derivative": { "buckets_path": "sales" #1 } } } } } } ``` | 1 | buckets_path指示這個derivative聚合是想要得到sales_per_month日期直方圖聚合中sales聚合值的導數。 | 響應可能如下所示: ``` { "took": 11, "timed_out": false, "_shards": ..., "hits": ..., "aggregations": { "sales_per_month": { "buckets": [ { "key_as_string": "2015/01/01 00:00:00", "key": 1420070400000, "doc_count": 3, "sales": { "value": 550.0 } #1 }, { "key_as_string": "2015/02/01 00:00:00", "key": 1422748800000, "doc_count": 2, "sales": { "value": 60.0 }, "sales_deriv": { "value": -490.0 #2 } }, { "key_as_string": "2015/03/01 00:00:00", "key": 1425168000000, "doc_count": 2, #3 "sales": { "value": 375.0 }, "sales_deriv": { "value": 315.0 } } ] } } } ``` | 1 | 由于我們至少需要2個數據點來計算導數,因此第一個桶沒有值 | | 2 | 導數的單位默認和sales聚合以及父直方圖相同。所以在這種情況下,如果價格字段的單位是美元,導數的單位就是美元/月 | | 3 | doc_count表示桶中的文檔數 | ### 二級導數 可以把導數管道聚合鏈接到另一個管道聚合的結果,計算二級導數。如以下示例所示,它將計算總月銷售額的第一和第二階導數: ``` POST /sales/_search { "size": 0, "aggs" : { "sales_per_month" : { "date_histogram" : { "field" : "date", "interval" : "month" }, "aggs": { "sales": { "sum": { "field": "price" } }, "sales_deriv": { "derivative": { "buckets_path": "sales" } }, "sales_2nd_deriv": { "derivative": { "buckets_path": "sales_deriv" #1 } } } } } } ``` | 1 | 二階導數的buckets_path指向一階導數的名稱 | 響應可能如下所示: ``` { "took": 50, "timed_out": false, "_shards": ..., "hits": ..., "aggregations": { "sales_per_month": { "buckets": [ { "key_as_string": "2015/01/01 00:00:00", "key": 1420070400000, "doc_count": 3, "sales": { "value": 550.0 } #1 }, { "key_as_string": "2015/02/01 00:00:00", "key": 1422748800000, "doc_count": 2, "sales": { "value": 60.0 }, "sales_deriv": { "value": -490.0 } #2 }, { "key_as_string": "2015/03/01 00:00:00", "key": 1425168000000, "doc_count": 2, "sales": { "value": 375.0 }, "sales_deriv": { "value": 315.0 }, "sales_2nd_deriv": { "value": 805.0 } } ] } } } ``` | 1 | 由于我們至少需要2個數據點,所以前兩個桶沒有二級導數 | | 2 | 一級導數計算二級導數 | ### Units(單位) 導數聚合允許指定導數值的單位。這將在響應normalized_value中返回一個額外的字段,匯報在X軸單位下的導數。在下面的例子中,我們計算出每月銷售額的導數,但要求銷售的導數按天計算: ``` POST /sales/_search { "size": 0, "aggs" : { "sales_per_month" : { "date_histogram" : { "field" : "date", "interval" : "month" }, "aggs": { "sales": { "sum": { "field": "price" } }, "sales_deriv": { "derivative": { "buckets_path": "sales", "unit": "day" #1 } } } } } } ``` | 1 | unit指定用于導數計算的X軸的單位 | 響應可能如下所示: ``` { "took": 50, "timed_out": false, "_shards": ..., "hits": ..., "aggregations": { "sales_per_month": { "buckets": [ { "key_as_string": "2015/01/01 00:00:00", "key": 1420070400000, "doc_count": 3, "sales": { "value": 550.0 } #1 }, { "key_as_string": "2015/02/01 00:00:00", "key": 1422748800000, "doc_count": 2, "sales": { "value": 60.0 }, "sales_deriv": { "value": -490.0, #2 "normalized_value": -15.806451612903226 #3 } }, { "key_as_string": "2015/03/01 00:00:00", "key": 1425168000000, "doc_count": 2, "sales": { "value": 375.0 }, "sales_deriv": { "value": 315.0, "normalized_value": 11.25 } } ] } } } ``` | 1,2 | value值是原單位:按月 | | 3 | `normalized_value值是請求的單位:按天` |
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看