Browse Source

[DOCS] document that date and date_nanos fields support synthetic source (#89968)

Alan Woodward 3 years ago
parent
commit
224f48e637

+ 2 - 0
docs/reference/mapping/fields/synthetic-source.asciidoc

@@ -31,6 +31,8 @@ types:
 ** <<aggregate-metric-double-synthetic-source, `aggregate_metric_double`>>
 ** <<boolean-synthetic-source,`boolean`>>
 ** <<numeric-synthetic-source,`byte`>>
+** <<date-synthetic-source,`date`>>
+** <<date-nanos-synthetic-source,`date_nanos`>>
 ** <<dense-vector-synthetic-source,`dense_vector`>>
 ** <<numeric-synthetic-source,`double`>>
 ** <<numeric-synthetic-source,`float`>>

+ 35 - 0
docs/reference/mapping/types/date.asciidoc

@@ -230,3 +230,38 @@ Which will reply with a date like:
   }
 }
 ----
+
+[[date-synthetic-source]]
+==== Synthetic source preview:[]
+`date` fields support <<synthetic-source,synthetic `_source`>> in their
+default configuration. Synthetic `_source` cannot be used together with
+<<copy-to,`copy_to`>>, <<ignore-malformed,`ignore_malformed`>> set to true
+or with <<doc-values,`doc_values`>> disabled.
+
+Synthetic source always sorts `date` fields. For example:
+[source,console,id=synthetic-source-date-example]
+----
+PUT idx
+{
+  "mappings": {
+    "_source": { "mode": "synthetic" },
+    "properties": {
+      "date": { "type": "date" }
+    }
+  }
+}
+PUT idx/_doc/1
+{
+  "date": ["2015-01-01T12:10:30Z", "2014-01-01T12:10:30Z"]
+}
+----
+// TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/]
+
+Will become:
+[source,console-result]
+----
+{
+  "date": ["2014-01-01T12:10:30.000Z", "2015-01-01T12:10:30.000Z"]
+}
+----
+// TEST[s/^/{"_source":/ s/\n$/}/]

+ 39 - 1
docs/reference/mapping/types/date_nanos.asciidoc

@@ -75,7 +75,7 @@ GET my-index-000001/_search
 <5> Note that the `sort` values that are returned are all in
 nanoseconds-since-the-epoch.
 <6> Use `.nano` in scripts to return the nanosecond component of the date.
-<7> You can specify the format when fetching data using the <<search-fields-param,`fields` parameter>>.  
+<7> You can specify the format when fetching data using the <<search-fields-param,`fields` parameter>>.
 Use <<strict-date-time-nanos,`strict_date_optional_time_nanos`>> or you'll get a rounded result.
 
 ////
@@ -137,3 +137,41 @@ include::date.asciidoc[tag=decimal-warning]
 
 Aggregations are still on millisecond resolution, even when using a `date_nanos`
 field. This limitation also affects <<transforms,{transforms}>>.
+
+---
+
+[[date-nanos-synthetic-source]]
+==== Synthetic source preview:[]
+`date_nanos` fields support <<synthetic-source,synthetic `_source`>> in their
+default configuration. Synthetic `_source` cannot be used together with
+<<copy-to,`copy_to`>>, <<ignore-malformed,`ignore_malformed`>> set to true
+or with <<doc-values,`doc_values`>> disabled.
+
+Synthetic source always sorts `date_nanos` fields. For example:
+[source,console,id=synthetic-source-date-nanos-example]
+----
+PUT idx
+{
+  "mappings": {
+    "_source": { "mode": "synthetic" },
+    "properties": {
+      "date": { "type": "date_nanos" }
+    }
+  }
+}
+PUT idx/_doc/1
+{
+  "date": ["2015-01-01T12:10:30.000Z", "2014-01-01T12:10:30.000Z"]
+}
+----
+// TEST[s/$/\nGET idx\/_doc\/1?filter_path=_source\n/]
+
+Will become:
+[source,console-result]
+----
+{
+  "date": ["2014-01-01T12:10:30.000Z", "2015-01-01T12:10:30.000Z"]
+}
+----
+// TEST[s/^/{"_source":/ s/\n$/}/]
+