Pipeline aggregations work on the outputs produced from other aggregations rather than from document sets, adding information to the output tree. There are many different types of pipeline aggregation, each computing different information from other aggregations, but these types can be broken down into two families:
Parent
A family of pipeline aggregations that is provided with the output of its parent aggregation and is able to compute new buckets or new aggregations to add to existing buckets.
Sibling
Pipeline aggregations that are provided with the output of a sibling aggregation and are able to compute a new aggregation which will be at the same level as the sibling aggregation.
Pipeline aggregations can reference the aggregations they need to perform their computation by using thebuckets_pathparameter to indicate the paths to the required metrics. The syntax for defining these paths can be found in thebuckets_pathSyntaxsection below.
Pipeline aggregations cannot have sub-aggregations but depending on the type it can reference another pipeline in thebuckets_pathallowing pipeline aggregations to be chained. For example, you can chain together two derivatives to calculate the second derivative (i.e. a derivative of a derivative).
管道聚合處理的對(duì)象是其它聚合的輸出(桶或者桶的某些權(quán)值)誊酌,而不是直接針對(duì)文檔部凑。
管道聚合的作用是為輸出增加一些有用信息。
Avg Bucket Aggregation(sibliing)
桶均值聚合——基于兄弟聚合的某個(gè)權(quán)值碧浊,求所有桶的權(quán)值均值涂邀。
用于計(jì)算的兄弟聚合必須是多桶聚合。
用于計(jì)算的權(quán)值必須是數(shù)值類型箱锐。
Derivative Aggregation(parent)
求導(dǎo)聚合——基于父聚合(只能是histogram或date_histogram類型)的某個(gè)權(quán)值比勉,對(duì)權(quán)值求導(dǎo)。
用于求導(dǎo)的權(quán)值必須是數(shù)值類型驹止。
封閉直方圖(histogram)聚合的 min_doc_count 必須是 0浩聋。
Max Bucket Aggregation(sibling)
桶最大值聚合——基于兄弟聚合的某個(gè)權(quán)值,輸出權(quán)值最大的那一個(gè)桶臊恋。
用于計(jì)算的權(quán)值必須是數(shù)值類型衣洁。
用于計(jì)算的兄弟聚合必須是多桶聚合類型。
Min Bucket Aggregation(sibling)
桶最小值聚合——基于兄弟聚合的某個(gè)權(quán)值捞镰,輸出權(quán)值最小的一個(gè)桶闸与。
用于計(jì)算的權(quán)值必須是數(shù)值類型毙替。
用于計(jì)算的兄弟聚合必須是多桶聚合類型岸售。
Sum Buchet Aggregation(sibling)
桶求和聚合——基于兄弟聚合的權(quán)值,對(duì)所有桶的權(quán)值求和厂画。
用于計(jì)算的權(quán)值必須是數(shù)值類型凸丸。
用于計(jì)算的兄弟聚合必須是多桶聚合類型。
Stats Bucket Aggregation(sibling)
桶統(tǒng)計(jì)信息聚合——基于兄弟聚合的某個(gè)權(quán)值袱院,對(duì)【桶的信息】進(jìn)行一些統(tǒng)計(jì)學(xué)運(yùn)算(總計(jì)多少個(gè)桶屎慢、所有桶中該權(quán)值的最大值、最小等)忽洛。
用于計(jì)算的權(quán)值必須是數(shù)值類型腻惠。
用于計(jì)算的兄弟聚合必須是多桶聚合類型。
Extended Stats Bucket Aggregation(sibling)
擴(kuò)展桶統(tǒng)計(jì)聚合——基于兄弟聚合的某個(gè)權(quán)值欲虚,對(duì)【桶信息】進(jìn)行一系列統(tǒng)計(jì)學(xué)計(jì)算(比普通的統(tǒng)計(jì)聚合多了一些統(tǒng)計(jì)值)集灌。
用于計(jì)算的權(quán)值必須是數(shù)值類型。
用于計(jì)算的兄弟聚合必須是多桶聚合類型复哆。
Percentiles Bucket Aggregation(sibling)
桶百分比聚合——基于兄弟聚合的某個(gè)權(quán)值欣喧,計(jì)算權(quán)值的百分百腌零。
用于計(jì)算的權(quán)值必須是數(shù)值類型。
用于計(jì)算的兄弟聚合必須是多桶聚合類型唆阿。
對(duì)百分百的計(jì)算是精確的(不像Percentiles Metric聚合是近似值)益涧,所以可能會(huì)消耗大量?jī)?nèi)存
Moving Average Aggregation(parent)
窗口平均值聚合——基于已經(jīng)排序過(guò)的數(shù)據(jù),計(jì)算出處在當(dāng)前出口中數(shù)據(jù)的平均值驯鳖。
比如窗口大小為 5 闲询,對(duì)數(shù)據(jù) 1—10 的部分窗口平均值如下:
(1 + 2 + 3 + 4 + 5) / 5 = 3
(2 + 3 + 4 + 5 + 6) / 5 = 4
(3 + 4 + 5 + 6 + 7) / 5 = 5
Cumulative Sum Aggregation(parent)
累計(jì)和聚合——基于父聚合(只能是histogram或date_histogram類型)的某個(gè)權(quán)值,對(duì)權(quán)值在每一個(gè)桶中求所有之前的桶的該值累計(jì)的和臼隔。
用于計(jì)算的權(quán)值必須是數(shù)值類型嘹裂。
封閉直方圖(histogram)聚合的 min_doc_count 必須是 0。
Bucket Script Aggregation(parent)
桶腳本聚合——基于父聚合的【一個(gè)或多個(gè)權(quán)值】摔握,對(duì)這些權(quán)值通過(guò)腳本進(jìn)行運(yùn)算寄狼。
用于計(jì)算的父聚合必須是多桶聚合。
用于計(jì)算的權(quán)值必須是數(shù)值類型氨淌。
執(zhí)行腳本必須要返回?cái)?shù)值型結(jié)果泊愧。
Bucket Selector Aggregation(parent)
桶選擇器聚合——基于父聚合的【一個(gè)或多個(gè)權(quán)值】,通過(guò)腳本對(duì)權(quán)值進(jìn)行計(jì)算盛正,并決定父聚合的哪些桶需要保留删咱,其余的將被丟棄。
用于計(jì)算的父聚合必須是多桶聚合豪筝。
用于計(jì)算的權(quán)值必須是數(shù)值類型痰滋。
運(yùn)算的腳本必須是返回 boolean 類型,如果腳本是腳本表達(dá)式形式給出续崖,那么允許返回?cái)?shù)值類型敲街。
Serial Differencing Aggregation(parent)
串行差分聚合——基于父聚合(只能是histogram或date_histogram類型)的某個(gè)權(quán)值,對(duì)權(quán)值值進(jìn)行差分運(yùn)算严望,(取時(shí)間間隔多艇,后一刻的值減去前一刻的值:f(X) = f(Xt) – f(Xt-n))。
用于計(jì)算的父聚合必須是多桶聚合像吻。