1
0
Эх сурвалжийг харах

[DOCS] Add example of ds index template with date_nanos mapping (#59535)

James Rodewig 5 жил өмнө
parent
commit
5f01ffddec

+ 28 - 0
docs/reference/data-streams/set-up-a-data-stream.asciidoc

@@ -166,6 +166,9 @@ settings of a stream's backing indices may require reindexing. See
 The following <<indices-templates,put index template API>> request
 configures the `logs_data_stream` template.
 
+Because no field mapping is specified, the `@timestamp` field uses the `date`
+field data type by default.
+
 [source,console]
 ----
 PUT /_index_template/logs_data_stream
@@ -180,6 +183,31 @@ PUT /_index_template/logs_data_stream
 }
 ----
 // TEST[continued]
+
+The following template maps `@timestamp` as a `date_nanos` field.
+
+[source,console]
+----
+PUT /_index_template/logs_data_stream
+{
+  "index_patterns": [ "logs*" ],
+  "data_stream": { },
+  "template": {
+    "mappings": {
+      "properties": {
+        "@timestamp": { "type": "date_nanos" }    <1>
+      }
+    },
+    "settings": {
+      "index.lifecycle.name": "logs_policy"
+    }
+  }
+}
+----
+// TEST[continued]
+
+<1> Maps `@timestamp` as a `date_nanos` field. You can include other supported
+mapping parameters in this field mapping.
 ====
 
 NOTE: You cannot delete an index template that's in use by a data stream.