elasticsearch/docs/reference/mapping
Luca Belluccini 2d3bcc483d
[DOCS] Warn only one date format is added to the field date formats when using dynamic_date_formats (#88915)
* [DOCS] Warn only one date format is added to the field date formats

When using multiple options in `dynamic_date_formats`, only one of the formats of the first document having a date matching one of the date formats provided will be used.

E.g.
```
PUT my-index-000001
{
  "mappings": {
    "dynamic_date_formats": [ "yyyy/MM", "MM/dd/yyyy"]
  }
}

PUT my-index-000001/_doc/1
{
  "create_date": "09/25/2015"
}
```

The generated mappings will be:
```
    "mappings": {
      "dynamic_date_formats": [
        "yyyy/MM",
        "MM/dd/yyyy"
      ],
      "properties": {
        "create_date": {
          "type": "date",
          "format": "MM/dd/yyyy"
        }
      }
    },
```

Indexing a document with `2015/12` would lead to the `format` `"yyyy/MM"` being used for the `create_date`.

This can be misleading especially if the user is using multiple date formats on the same field.
The first document will determine the format of the `date` field being detected.

Maybe we should provide an additional example, such as:
```
PUT my-index-000001
{
  "mappings": {
    "dynamic_date_formats": [ "yyyy/MM||MM/dd/yyyy"]
  }
}
```

My wording is not great, so feel free to amend/edit.

* Update docs/reference/mapping/dynamic/field-mapping.asciidoc

Reword and add code example

* Turned discussion of the two syntaxes into an admonition

* Fix failing tests

Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
2022-08-11 10:43:53 +02:00
..
dynamic [DOCS] Warn only one date format is added to the field date formats when using dynamic_date_formats (#88915) 2022-08-11 10:43:53 +02:00
fields Add synthetic_source support to aggregate_metric_double fields (#88909) 2022-08-01 20:42:25 +03:00
params Fix a typo in date format docs (#87018) 2022-07-05 12:15:13 +02:00
types [DOCS] Move completion type asciidoc (#89086) 2022-08-04 10:02:28 +02:00
dynamic-mapping.asciidoc [DOCS] Clean up index template xrefs (#67264) 2021-01-11 12:38:09 -05:00
explicit-mapping.asciidoc [DOCS] Replace put with create or update in API names (#70330) 2021-03-15 14:49:44 -04:00
fields.asciidoc Support fetching _tier field value (#71379) 2021-04-08 11:41:52 -07:00
mapping-settings-limit.asciidoc [DOCS] Add TSDS docs, take two (#87703) 2022-06-16 12:44:10 -04:00
params.asciidoc Add support for dots in field names for metrics usecases (#86166) 2022-05-17 16:34:39 +02:00
removal_of_types.asciidoc [DOCS] Fix double spaces (#71082) 2021-03-31 09:57:47 -04:00
runtime.asciidoc [Docs] Fix runtime grok script example (#87851) 2022-07-05 10:53:24 -04:00
types.asciidoc [DOCS] Move completion type asciidoc (#89086) 2022-08-04 10:02:28 +02:00