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: manage-data/lifecycle/rollup/getting-started-api.md
+173-2Lines changed: 173 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -272,8 +272,179 @@ Which returns a corresponding response:
272
272
273
273
In addition to being more complicated (date histogram and a terms aggregation, plus an additional average metric), you’ll notice the date_histogram uses a `7d` interval instead of `60m`.
274
274
275
+
This quickstart should have provided a concise overview of the core functionality that Rollup exposes. There are more tips and things to consider when setting up Rollups, which you can find throughout the rest of this section. You may also explore the [REST API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-rollup-get-jobs) for an overview of what is available.
275
276
276
-
## Conclusion [_conclusion]
277
+
## Historical-only search example
277
278
278
-
This quickstart should have provided a concise overview of the core functionality that Rollup exposes. There are more tips and things to consider when setting up Rollups, which you can find throughout the rest of this section. You may also explore the [REST API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-rollup-get-jobs) for an overview of what is available.
279
+
Suppose you have an index named `sensor-1` that contains raw data, and you've created a {{rollup-job}} with the following configuration:
280
+
281
+
```console
282
+
PUT _rollup/job/sensor
283
+
{
284
+
"index_pattern": "sensor-*",
285
+
"rollup_index": "sensor_rollup",
286
+
"cron": "*/30 * * * * ?",
287
+
"page_size": 1000,
288
+
"groups": {
289
+
"date_histogram": {
290
+
"field": "timestamp",
291
+
"fixed_interval": "1h",
292
+
"delay": "7d"
293
+
},
294
+
"terms": {
295
+
"fields": [ "node" ]
296
+
}
297
+
},
298
+
"metrics": [
299
+
{
300
+
"field": "temperature",
301
+
"metrics": [ "min", "max", "sum" ]
302
+
},
303
+
{
304
+
"field": "voltage",
305
+
"metrics": [ "avg" ]
306
+
}
307
+
]
308
+
}
309
+
```
310
+
% TEST[setup:sensor_index]
311
+
312
+
This rolls up the `sensor-*` pattern and stores the results in `sensor_rollup`.
313
+
To search this rolled up data, use the `_rollup_search` endpoint.
314
+
You can use Query DSL to search the rolled-up data:
The response follows the same structure as a standard query with aggregations: it includes metadata about the request (`took`, `_shards`, etc.), an empty hits section (as rollup searches do not return individual documents), and the aggregation results.
353
+
354
+
Rollup searches are limited to the functionality defined in the {{rollup-job}} configuration. For example, if the `avg` metric was not configured for the `temperature` field, calculating the average temperature is not possible. Running such a query results in an error:
355
+
356
+
```console
357
+
GET sensor_rollup/_rollup_search
358
+
{
359
+
"size": 0,
360
+
"aggregations": {
361
+
"avg_temperature": {
362
+
"avg": {
363
+
"field": "temperature"
364
+
}
365
+
}
366
+
}
367
+
}
368
+
```
369
+
% TEST[continued]
370
+
% TEST[catch:/illegal_argument_exception/]
371
+
372
+
```console-result
373
+
{
374
+
"error": {
375
+
"root_cause": [
376
+
{
377
+
"type": "illegal_argument_exception",
378
+
"reason": "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
379
+
"stack_trace": ...
380
+
}
381
+
],
382
+
"type": "illegal_argument_exception",
383
+
"reason": "There is not a rollup job that has a [avg] agg with name [avg_temperature] which also satisfies all requirements of query.",
0 commit comments