Skip to content

Commit be44830

Browse files
authored
[DOCS] Add example of ds index template with date_nanos mapping (#59535) (#59570)
1 parent 68a199f commit be44830

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ settings of a stream's backing indices may require reindexing. See
169169
The following <<indices-templates,put index template API>> request
170170
configures the `logs_data_stream` template.
171171
172+
Because no field mapping is specified, the `@timestamp` field uses the `date`
173+
field data type by default.
174+
172175
[source,console]
173176
----
174177
PUT /_index_template/logs_data_stream
@@ -183,6 +186,31 @@ PUT /_index_template/logs_data_stream
183186
}
184187
----
185188
// TEST[continued]
189+
190+
The following template maps `@timestamp` as a `date_nanos` field.
191+
192+
[source,console]
193+
----
194+
PUT /_index_template/logs_data_stream
195+
{
196+
"index_patterns": [ "logs*" ],
197+
"data_stream": { },
198+
"template": {
199+
"mappings": {
200+
"properties": {
201+
"@timestamp": { "type": "date_nanos" } <1>
202+
}
203+
},
204+
"settings": {
205+
"index.lifecycle.name": "logs_policy"
206+
}
207+
}
208+
}
209+
----
210+
// TEST[continued]
211+
212+
<1> Maps `@timestamp` as a `date_nanos` field. You can include other supported
213+
mapping parameters in this field mapping.
186214
====
187215

188216
NOTE: You cannot delete an index template that's in use by a data stream.

0 commit comments

Comments
 (0)