<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>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Pipeline Aggregations 原文鏈接 : [https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-pipeline.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-pipeline.html) 譯文鏈接 : [Pipeline Aggregations](/display/Elasticsearch/Pipeline+Aggregations) 貢獻者 : @蘇濤,[ApacheCN](/display/~apachecn),[Apache中文網](/display/~apachechina) 警告 此功能是實驗性的,可能會在將來的版本中完全更改或刪除。Elastic將采取最大的努力來解決此問題,但實驗功能不受SLA官方功能的支持。 管道聚合工作于其他聚合產生的輸出結果而不是文檔集,用于向輸出樹添加信息。有不同類型的管道聚合,每一種從其他聚合中計算不同的信息,但這些類型可以分為以下兩個類型: **_Parent(父類)_** ?在父聚合輸出結果的基礎上進行管道聚合,可以在現有桶的基礎上計算新的桶或者聚合。 **_Sibling(同級)_** ? ? 在同級聚合輸出結果的基礎上進行管道聚合,并且能夠計算與同級聚合相同等級的新聚合。 管道聚合可以通過使用buckets_path參數來指示所需度量的路徑來引用他們執行計算所需的聚合。定義這些路徑的語法可以在下面的buckets_path語法部分找到。 管道聚合不能具有子聚合,但根據類型,可以引用buckets_path中的另一個管道,使管道聚合鏈接起來。例如,您可以將兩個衍生物連接在一起以計算二階導數(即衍生詞的衍生)。 注意 因為管道聚合僅在輸出結果中添加信息,當鏈接管道聚合的時候,每個管道聚合的輸出結果都會被包含在最終結果里。 ### buckets_path語法 大多數管道聚合需要另一個聚合作為它的輸入。輸入聚合通過buckets_path參數定義,該參數遵循特定格式: ``` AGG_SEPARATOR = '>' ; METRIC_SEPARATOR = '.' ; AGG_NAME = <the name of the aggregation> ; METRIC = <the name of the metric (in case of multi-value metrics aggregation)> ; PATH = <AGG_NAME> [ <AGG_SEPARATOR>, <AGG_NAME> ]* [ <METRIC_SEPARATOR>, <METRIC> ] ; ``` 例如,路徑"my_bucket&gt;my_stats.avg" 會將"my_stats"中的平均值指作為"my_bucket"桶聚合的輸入。 路徑跟管道聚合的位置是相對的;并不是絕對路徑。而且路徑不能沿著聚合樹“向上”返回。例如,在date_histogram(日期直方圖聚合)中嵌入移動平均值聚合,并引用一個“同級聚合”度量“the_sum”: ``` POST /_search { "aggs": { "my_date_histo":{ "date_histogram":{ "field":"timestamp", "interval":"day" }, "aggs":{ "the_sum":{ "sum":{ "field": "lemmings" } #1 }, "the_movavg":{ "moving_avg":{ "buckets_path": "the_sum" } #2 } } } } } ``` | 1 | 該度量稱為“the_sum” | | 2 | buckets_path通過相對路徑“the_sum”引用度量 | buckets_path也用于Sibling管道聚合,管道聚合是“靠近”一系列桶聚合而不是嵌入它們“里面”。例如,max_bucket聚合使用buckets_path指定嵌入在同級聚合中的度量: ``` POST /_search { "aggs" : { "sales_per_month" : { "date_histogram" : { "field" : "date", "interval" : "month" }, "aggs": { "sales": { "sum": { "field": "price" } } } }, "max_monthly_sales": { "max_bucket": { "buckets_path": "sales_per_month>sales" #1 } } } } ``` | 1 | `buckets_path`?指示max_bucket?聚合是想要得到`sales_per_month`?日期直方圖聚合中最大的月份值 | ### 特殊路徑 與指標路徑不同,`buckets_path`?可以使用特殊的"_count"路徑,讓管道聚合使用文檔計數作為輸入參數。例如,移動平均值聚合可以計算每個桶的文檔計數而不是給出具體的度量: ``` POST /_search { "aggs": { "my_date_histo": { "date_histogram": { "field":"timestamp", "interval":"day" }, "aggs": { "the_movavg": { "moving_avg": { "buckets_path": "_count" } #1 } } } } } ``` | 1 | 通過使用_count而不是度量名,我們可以計算直方圖中文檔計數的移動平均值 | buckets_path還可以使用“_bucket_count”和多桶聚合的路徑,以使該聚合在管道聚合中返回的是桶數而不是度量。例如,可以在此處使用bucket_selector過濾掉不包含terms聚合的桶: ``` POST /sales/_search { "size": 0, "aggs": { "histo": { "date_histogram": { "field": "date", "interval": "day" }, "aggs": { "categories": { "terms": { "field": "category" } }, "min_bucket_selector": { "bucket_selector": { "buckets_path": { "count": "categories._bucket_count" #1 }, "script": { "inline": "params.count != 0" } } } } } } } ``` | 1 | 通過使用_bucket_count而不是度量名稱,我們可以過濾掉它們不包含categories聚合的桶 | ### 處理聚合名稱中的點 支持替代語法來處理在名稱中具有點的聚合或度量,例如第99.9[百分位數](https://www.elastic.co/guide/en/elasticsearch/reference/5.4/search-aggregations-metrics-percentile-aggregation.html)。該度量可以參考如下格式: ``` "buckets_path": "my_percentile[99.9]" ``` ### 處理數據中的空值 現實世界中的數據通常是嘈雜的,有時候還會存在空數據——數據根本不存在。這可能有各種各樣的原因,最常見的原因是: ?落入桶中的文檔不包含必填字段 ?一個或多個桶沒有匹配到文檔 ?正在計算的度量不能生成值,可能是因為另一個相關的存儲區缺少一個值。一些管道聚合具有必須滿足的特定要求(例如,導數不能計算第一個值的度量,因為沒有先前的值,HoltWinters移動平均需要“預熱”數據開始計算等) Gap policies(缺口策略)是一個用來通知管道聚合當遭遇到數據缺口時應該執行哪種行為的機制。所有的管道聚合都支持`gap_policy`?參數指定Gap policies(缺口策略)。目前有兩種Gap policies(缺口策略)可以選擇: **_skip(跳過)_** 此選擇將缺失數據的桶視為不存在,會跳過這個桶并使用下一個可用值繼續計算。 **_insert_zeros(插入零值)_** 此選項會用零替代缺失值,而且管道聚合會照常進行計算。
                  <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>

                              哎呀哎呀视频在线观看