Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto-date histogram aggregations documentation #7630

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
59 changes: 59 additions & 0 deletions _aggregations/bucket/auto-interval-date-histogram.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
layout: default
title: Auto-date histogram
parent: Bucket aggregations
grand_parent: Aggregations
nav_order: 15
---

# Auto-date histogram
vagimeli marked this conversation as resolved.
Show resolved Hide resolved

The `auto_date_histogram` aggregation automatically creates date histogram buckets based on the time range of your data. This aggregation is particularly useful when you are working with time-series data and want to visualize or analyze data over different time intervals without having to specify the bucket size manually.
vagimeli marked this conversation as resolved.
Show resolved Hide resolved

To use the `auto_date_histogram` aggregation, you need to specify the field containing the date or timestamp values. Additionally, you can provide optional parameters to customize the behavior of the aggregation.

For example, you can use the `auto_date_histogram` aggregation to :
vagimeli marked this conversation as resolved.
Show resolved Hide resolved

```json
vagimeli marked this conversation as resolved.
Show resolved Hide resolved
GET /sample-index/_search
{
"size": 0,
"aggs": {
"histogram": {
"auto_date_histogram": {
"field": "timestamp",
"buckets": 2,
"minimum_interval": "day",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this parameter specify?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bowenlan-amzn Please help me address the information gap. See comment above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The accepted units for minimum_interval are:

year
month
day
hour
minute
second

auto date histogram won't try the interval shorter than the one specified.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bowenlan-amzn Please confirm the revised text is technically accurate. Thank you.

"time_zone": "America/Los_Angeles",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the possible formats for time_zone?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bowenlan-amzn Please help me address the information gap. See comment above.

"format": "yyyy-MM-dd HH:mm:ss"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the possible formats for dates?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bowenlan-amzn Please help me address the information gap. See comment above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For any time data (date field), format and timezone are consistent. I would expect we have a different documentation page about these

}
}
}
}
```
{% include copy-curl.html %}

#### Example response
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this heading, I would use a sentence describing what the response contains.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bowenlan-amzn Please help me address the information gap. Can you explain the response from a novice user point of view?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can provide the data you have indexed, this can just be the response of the previous search request

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bowenlan-amzn Please verify the revised text is technically accurate. Thank you.


```json
...
"aggregations": {
"histogram": {
"buckets": [
{
"key_as_string": "2023-04-01 00:00:00",
"key": 1680332400000,
"doc_count": 2
},
{
"key_as_string": "2023-04-02 00:00:00",
"key": 1680418800000,
"doc_count": 1
}
],
"interval": "1d"
}
}
}
```
{% include copy-curl.html %}
Loading