-
Notifications
You must be signed in to change notification settings - Fork 578
adding format mapping parameter docs #9507
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
Merged
natebower
merged 9 commits into
opensearch-project:main
from
AntonEliatra:adding-format-mapping-parameter-docs
Apr 15, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
710b842
adding format mapping parameter docs
AntonEliatra 63ff624
adding format mapping parameter docs
AntonEliatra 845e5b3
fixing vale errors
AntonEliatra ac89375
updating links on index page
AntonEliatra 138a0f4
Apply suggestions from code review
AntonEliatra 30c6673
updating as pr review comments
AntonEliatra 6a6d4a8
Apply suggestions from code review
AntonEliatra cb00ae0
Merge branch 'main' into adding-format-mapping-parameter-docs
AntonEliatra e9c748b
Apply suggestions from code review
AntonEliatra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
--- | ||
layout: default | ||
title: Format | ||
parent: Mapping parameters | ||
grand_parent: Mapping and field types | ||
nav_order: 50 | ||
has_children: false | ||
has_toc: false | ||
--- | ||
|
||
# Format | ||
|
||
The `format` mapping parameter specifies the [built-in date formats]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/date/#built-in-formats) that a date field can accept during indexing. By defining the expected date formats, you ensure that date values are correctly parsed and stored, facilitating accurate search and aggregation operations. | ||
|
||
## Example: Defining a custom date format | ||
|
||
Create an `events` index with the `event_date` field configured to a custom `yyyy-MM-dd HH:mm:ss` date format: | ||
|
||
```json | ||
PUT events | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"event_date": { | ||
"type": "date", | ||
"format": "yyyy-MM-dd HH:mm:ss" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
Index a document using the specified format for the `event_date` field: | ||
|
||
```json | ||
PUT events/_doc/1 | ||
{ | ||
"event_name": "Conference", | ||
"event_date": "2025-03-26 15:30:00" | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Example: Using multiple date formats | ||
|
||
Create an index containing a `log_timestamp` field, which accepts both the custom `yyyy-MM-dd HH:mm:ss` date format and the `epoch_millis` format: | ||
|
||
```json | ||
PUT logs | ||
{ | ||
"mappings": { | ||
"properties": { | ||
"log_timestamp": { | ||
"type": "date", | ||
"format": "yyyy-MM-dd HH:mm:ss||epoch_millis" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
Index the first document using the custom format: | ||
|
||
```json | ||
PUT logs/_doc/1 | ||
{ | ||
"message": "System rebooted", | ||
"log_timestamp": "2025-03-26 08:45:00" | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
Index the second document using the millisecond format: | ||
|
||
```json | ||
PUT logs/_doc/2 | ||
{ | ||
"message": "System updated", | ||
"log_timestamp": 1711442700000 | ||
} | ||
``` | ||
{% include copy-curl.html %} | ||
|
||
## Built-in date formats | ||
|
||
For a comprehensive list of built-in date formats, see [Built-in formats]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/date/#built-in-formats). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.