mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-30 18:33:26 -04:00
Generate timestamp when path is null
Index process fails when having `_timestamp` enabled and `path` option is set. It fails with a `TimestampParsingException[failed to parse timestamp [null]]` message. Reproduction: ``` DELETE test PUT test { "mappings": { "test": { "_timestamp" : { "enabled" : "yes", "path" : "post_date" } } } } PUT test/test/1 { "foo": "bar" } ``` You can define a default value for when timestamp is not provided within the index request or in the `_source` document. By default, the default value is `now` which means the date the document was processed by the indexing chain. You can disable that default value by setting `default` to `null`. It means that `timestamp` is mandatory: ``` { "tweet" : { "_timestamp" : { "enabled" : true, "default" : null } } } ``` If you don't provide any timestamp value, indexation will fail. You can also set the default value to any date respecting timestamp format: ``` { "tweet" : { "_timestamp" : { "enabled" : true, "format" : "YYYY-MM-dd", "default" : "1970-01-01" } } } ``` If you don't provide any timestamp value, indexation will fail. Closes #4718. Closes #7036.
This commit is contained in:
parent
6b39aa615e
commit
85eb0ea0e7
6 changed files with 387 additions and 31 deletions
|
@ -4,7 +4,7 @@
|
|||
The `_timestamp` field allows to automatically index the timestamp of a
|
||||
document. It can be provided externally via the index request or in the
|
||||
`_source`. If it is not provided externally it will be automatically set
|
||||
to the date the document was processed by the indexing chain.
|
||||
to a <<mapping-timestamp-field-default,default date>>.
|
||||
|
||||
[float]
|
||||
==== enabled
|
||||
|
@ -60,6 +60,7 @@ Note, using `path` without explicit timestamp value provided requires an
|
|||
additional (though quite fast) parsing phase.
|
||||
|
||||
[float]
|
||||
[[mapping-timestamp-field-format]]
|
||||
==== format
|
||||
|
||||
You can define the <<mapping-date-format,date
|
||||
|
@ -80,3 +81,46 @@ format>> used to parse the provided timestamp value. For example:
|
|||
|
||||
Note, the default format is `dateOptionalTime`. The timestamp value will
|
||||
first be parsed as a number and if it fails the format will be tried.
|
||||
|
||||
[float]
|
||||
[[mapping-timestamp-field-default]]
|
||||
==== default
|
||||
|
||||
You can define a default value for when timestamp is not provided
|
||||
within the index request or in the `_source` document.
|
||||
|
||||
By default, the default value is `now` which means the date the document was processed by the indexing chain.
|
||||
|
||||
You can disable that default value by setting `default` to `null`. It means that `timestamp` is mandatory:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"tweet" : {
|
||||
"_timestamp" : {
|
||||
"enabled" : true,
|
||||
"default" : null
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
If you don't provide any timestamp value, indexation will fail.
|
||||
|
||||
You can also set the default value to any date respecting <<mapping-timestamp-field-format,timestamp format>>:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
{
|
||||
"tweet" : {
|
||||
"_timestamp" : {
|
||||
"enabled" : true,
|
||||
"format" : "YYYY-MM-dd",
|
||||
"default" : "1970-01-01"
|
||||
}
|
||||
}
|
||||
}
|
||||
--------------------------------------------------
|
||||
|
||||
If you don't provide any timestamp value, indexation will fail.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue