[[mapping-timestamp-field]] === `_timestamp` field deprecated[2.0.0,The `_timestamp` field is deprecated. Instead, use a normal <> field and set its value explicitly] The `_timestamp` field, when enabled, allows a timestamp to be indexed and stored with a document. The timestamp may be specified manually, generated automatically, or set to a default value: [source,js] ------------------------------------ PUT my_index { "mappings": { "my_type": { "_timestamp": { <1> "enabled": true } } } } PUT my_index/my_type/1?timestamp=2015-01-01 <2> { "text": "Timestamp as a formatted date" } PUT my_index/my_type/2?timestamp=1420070400000 <3> { "text": "Timestamp as milliseconds since the epoch" } PUT my_index/my_type/3 <4> { "text": "Autogenerated timestamp set to now()" } ------------------------------------ // CONSOLE <1> Enable the `_timestamp` field with default settings. <2> Set the timestamp manually with a formatted date. <3> Set the timestamp with milliseconds since the epoch. <4> Auto-generates a timestamp with <>. The behaviour of the `_timestamp` field can be configured with the following parameters: `default`:: A default value to be used if none is provided. Defaults to <>. `format`:: The <> (or formats) to use when parsing timestamps. Defaults to `epoch_millis||strictDateOptionalTime`. `ignore_missing`:: If `true` (default), replace missing timestamps with the `default` value. If `false`, throw an exception. The value of the `_timestamp` field is accessible in queries, aggregations, scripts, and when sorting: [source,js] -------------------------- GET my_index/_search { "query": { "range": { "_timestamp": { <1> "gte": "2015-01-01" } } }, "aggs": { "Timestamps": { "terms": { "field": "_timestamp", <2> "size": 10 } } }, "sort": [ { "_timestamp": { <3> "order": "desc" } } ], "script_fields": { "Timestamp": { "script": "doc['_timestamp']" <4> } } } -------------------------- // CONSOLE // TEST[continued] <1> Querying on the `_timestamp` field <2> Aggregating on the `_timestamp` field <3> Sorting on the `_timestamp` field <4> Accessing the `_timestamp` field in scripts (inline scripts must be <> for this example to work)