You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/data-analysis/aggregations/search-aggregations-bucket-composite-aggregation.md
+123Lines changed: 123 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,64 @@ Unlike the other `multi-bucket` aggregations, you can use the `composite` aggreg
18
18
19
19
The composite buckets are built from the combinations of the values extracted/created for each document and each combination is considered as a composite bucket.
@@ -27,6 +85,8 @@ For example, consider the following document:
27
85
}
28
86
```
29
87
88
+
% NOTCONSOLE
89
+
30
90
Using `keyword` and `number` as source fields for the aggregation results in the following composite buckets:
31
91
32
92
```js
@@ -38,6 +98,8 @@ Using `keyword` and `number` as source fields for the aggregation results in the
38
98
{ "keyword":"bar", "number":76 }
39
99
```
40
100
101
+
% NOTCONSOLE
102
+
41
103
## Value sources [_value_sources]
42
104
43
105
The `sources` parameter defines the source fields to use when building composite buckets. The order that the `sources` are defined controls the order that the keys are returned.
Although similar, the `terms` value source doesn’t support the same set of parameters as the `terms` aggregation. For other supported value source parameters, see:
115
203
116
204
*[Order](#_order)
@@ -180,6 +268,31 @@ GET /_search
180
268
}
181
269
```
182
270
271
+
% [source,console-result]
272
+
% ----
273
+
% {
274
+
% "timed_out": false,
275
+
% "took": "$body.took",
276
+
% "_shards": {
277
+
% "total": 1,
278
+
% "successful": 1,
279
+
% "failed": 0,
280
+
% "skipped": 0
281
+
% },
282
+
% "hits": "$body.hits",
283
+
% "aggregations": {
284
+
% "my_buckets": {
285
+
% "after_key": { "price": 20.0 },
286
+
% "buckets": [
287
+
% { "key": { "price": 10.0 }, "doc_count": 2 },
288
+
% { "key": { "price": 15.0 }, "doc_count": 1 },
289
+
% { "key": { "price": 20.0 }, "doc_count": 2 }
290
+
% ]
291
+
% }
292
+
% }
293
+
% }
294
+
% ----
295
+
183
296
184
297
### Date histogram [_date_histogram]
185
298
@@ -311,6 +424,8 @@ Instead of a single bucket starting at midnight, the above request groups the do
To get the next set of buckets, resend the same aggregation with the `after` parameter set to the `after_key` value returned in the response. For example, this request uses the `after_key` value provided in the previous response:
Copy file name to clipboardExpand all lines: docs/reference/data-analysis/aggregations/search-aggregations-metrics-avg-aggregation.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,8 @@ POST /exams/_search?size=0
20
20
}
21
21
```
22
22
23
+
% TEST[setup:exams]
24
+
23
25
The above aggregation computes the average grade over all documents. The aggregation type is `avg` and the `field` setting defines the numeric field of the documents the average will be computed on. The above will return the following:
24
26
25
27
```console-result
@@ -33,6 +35,8 @@ The above aggregation computes the average grade over all documents. The aggrega
0 commit comments