Date Index Name
Synopsis
Creates dynamic index names based on date fields in documents by combining a configurable prefix with formatted dates.
Schema
date_index_name:
- field: <ident>
- date_rounding: <enum>
- date_formats: <string[]>
- description: <text>
- if: <script>
- ignore_failure: <boolean>
- ignore_missing: <boolean>
- index_name_format: <string>
- index_name_prefix: <string>
- locale: <string>
- on_failure: <processor[]>
- on_success: <processor[]>
- tag: <string>
- time_zone: <string>
Configuration
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Field containing the date/timestamp to process |
date_rounding | Y | - | Time unit to round to: y (year), M (month), w (week), d (day), h (hour), m (minute), s (second) |
date_formats | N | [RFC3339] | Array of date format patterns to try when parsing the date field |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue processing if parsing fails |
ignore_missing | N | false | Skip if the date field is missing |
index_name_format | N | 2006-01-02 | Go time format pattern for the output date |
index_name_prefix | N | - | String to prepend to the formatted date |
locale | N | - | Locale for date parsing |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
time_zone | N | UTC | Timezone for date parsing |
Details
The processor extracts a date from a specified field, applies configured rounding, and generates an index name by combining a prefix with the formatted date.
The date can be rounded to various time units (year, month, week, day, hour, minute, second) and formatted according to specified patterns. This is particularly useful for time-series data where you want to organize documents into time-based indices.
With the weekly rounding (w
), the date is rounded to the start of the ISO week (Monday).
The date parsing will fail if none of the specified date formats match the input. Consider setting ignore_failure
to true
if errors should be tolerated.
Examples
Monthly
Rounding dates to months... |
|
creates a monthly index name: |
|
Daily
Dates from a nested field... |
|
create a daily index name: |
|
Weekly
Rounding to the start of the ISO week... |
|
creates a weekly index name: |
|