Skip to content

Commit 56b4709

Browse files
tanik98kolchfa-awsnatebower
authored
Update supported field level documents for derived source (#10994)
* Update supported field level documents for derived source Signed-off-by: Tanik Pansuriya <[email protected]> * Doc review Signed-off-by: Fanit Kolchina <[email protected]> * Small rewording Signed-off-by: Fanit Kolchina <[email protected]> * Apply suggestions from code review Signed-off-by: Nathan Bower <[email protected]> * Apply suggestions from code review Signed-off-by: kolchfa-aws <[email protected]> --------- Signed-off-by: Tanik Pansuriya <[email protected]> Signed-off-by: Fanit Kolchina <[email protected]> Signed-off-by: Nathan Bower <[email protected]> Signed-off-by: kolchfa-aws <[email protected]> Co-authored-by: Fanit Kolchina <[email protected]> Co-authored-by: Nathan Bower <[email protected]> Co-authored-by: kolchfa-aws <[email protected]>
1 parent aad0106 commit 56b4709

File tree

8 files changed

+557
-4
lines changed

8 files changed

+557
-4
lines changed

_mappings/supported-field-types/boolean.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,83 @@ The script returns the value of `a` as `true`, `key` returns the value of `a` as
158158
}
159159
}
160160
```
161+
162+
## Derived source
163+
164+
When an index uses [derived source]({{site.url}}{{site.baseurl}}/field-types/metadata-fields/source/#derived-source), OpenSearch may sort values in a multi-value `boolean` field during source reconstruction. The following example shows how OpenSearch processes mixed `boolean` inputs.
165+
166+
Create an index that enables derived source and configures a `boolean` field named `a`:
167+
168+
```json
169+
PUT /sample-index1
170+
{
171+
"settings": {
172+
"index": {
173+
"derived_source": {
174+
"enabled": true
175+
}
176+
}
177+
},
178+
"mappings": {
179+
"properties": {
180+
"a": {"type": "boolean"}
181+
}
182+
}
183+
}
184+
```
185+
186+
Index a document into the index:
187+
188+
```json
189+
PUT sample-index1/_doc/1
190+
{
191+
"a": [false, "true", "false", true, ""]
192+
}
193+
```
194+
195+
After OpenSearch reconstructs `_source`, the derived `_source` is as follows:
196+
197+
```json
198+
{
199+
"a": [false, false, false, true, true]
200+
}
201+
```
202+
203+
If the field mapping defines a [`null_value`]({{site.url}}{{site.baseurl}}/field-types/mapping-parameters/null-value/), any ingested null values are replaced with that value during reconstruction. The following example demonstrates how `null_value` affects derived source output.
204+
205+
Create an index that enables derived source and configures a `null_value` for the `boolean` field `a`:
206+
207+
```json
208+
PUT sample-index2
209+
{
210+
"settings": {
211+
"index": {
212+
"derived_source": {
213+
"enabled": true
214+
}
215+
}
216+
},
217+
"mappings": {
218+
"properties": {
219+
"a": {"type": "boolean", "null_value": true}
220+
}
221+
}
222+
}
223+
```
224+
225+
Index a document into the index:
226+
227+
```json
228+
PUT sample-index2/_doc/1
229+
{
230+
"a": [null, true, "false"]
231+
}
232+
```
233+
234+
After OpenSearch reconstructs `_source`, the derived `_source` is as follows:
235+
236+
```json
237+
{
238+
"a": [false, true, true]
239+
}
240+
```

_mappings/supported-field-types/date-nanos.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,48 @@ The response contains only the nanosecond parts of the fields:
290290
]
291291
}
292292
}
293-
```
293+
```
294+
295+
## Derived source
296+
297+
When an index uses [derived source]({{site.url}}{{site.baseurl}}/field-types/metadata-fields/source/#derived-source), OpenSearch may sort values in multi-value date fields during source reconstruction. When configuring multiple date formats separated by `||` under the `format` mapping parameter, derived source returns results in the first provided format.
298+
299+
Create an index that enables derived source and configures a `date_nanos` field with multiple formats:
300+
301+
```json
302+
PUT sample-index1
303+
{
304+
"settings": {
305+
"index": {
306+
"derived_source": {
307+
"enabled": true
308+
}
309+
}
310+
},
311+
"mappings": {
312+
"properties": {
313+
"date_nanos": {
314+
"type": "date_nanos",
315+
"format": "strict_date_optional_time_nanos||strict_date_optional_time||epoch_millis"
316+
}
317+
}
318+
}
319+
}
320+
```
321+
322+
Index a document with mixed date formats into the index:
323+
324+
```json
325+
PUT sample-index1/_doc/1
326+
{
327+
"date_nanos": [1758504860, "2025-09-22T00:34", "2025-09-22T01:34:20Z"]
328+
}
329+
```
330+
331+
After OpenSearch reconstructs `_source`, the derived `_source` is as follows:
332+
333+
```json
334+
{
335+
"date_nanos": ["2025-09-22T00:34:00.000000000Z", "2025-09-22T01:34:00.000000000Z", "2025-09-22T01:34:00.000000000Z"]
336+
}
337+
```

_mappings/supported-field-types/date.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,47 @@ The response contains both documents:
361361
}
362362
}
363363
```
364+
365+
## Derived source
366+
367+
When an index uses [derived source]({{site.url}}{{site.baseurl}}/field-types/metadata-fields/source/#derived-source), OpenSearch may sort values in multi-value date fields during source reconstruction. When configuring multiple date formats separated by `||` under the `format` mapping parameter, derived source returns results in the first provided format.
368+
369+
Create an index that enables derived source and configures a `date` field with multiple formats:
370+
371+
```json
372+
PUT sample-index1
373+
{
374+
"settings": {
375+
"index": {
376+
"derived_source": {
377+
"enabled": true
378+
}
379+
}
380+
},
381+
"mappings": {
382+
"properties": {
383+
"date": {
384+
"type": "date",
385+
"format": "strict_date_time_no_millis||strict_date_optional_time||epoch_millis"
386+
}
387+
}
388+
}
389+
}
390+
```
391+
392+
Index a document with mixed date formats into the index:
393+
394+
```json
395+
PUT sample-index1/_doc/1
396+
{
397+
"date": [1758504860, "2025-09-22T00:34", "2025-09-22T01:34:20Z"]
398+
}
399+
```
400+
401+
After OpenSearch reconstructs `_source`, all dates are in the `strict_date_time_no_millis` format:
402+
403+
```json
404+
{
405+
"date": ["2025-09-22T00:34:00.000Z", "2025-09-22T01:34:00.000Z", "2025-09-22T01:34:00.000Z"]
406+
}
407+
```

_mappings/supported-field-types/geo-point.md

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,93 @@ Parameter | Description
113113
:--- | :---
114114
`ignore_malformed` | A Boolean value that specifies to ignore malformed values and not to throw an exception. Valid values for latitude are [-90, 90]. Valid values for longitude are [-180, 180]. Default is `false`.
115115
`ignore_z_value` | Specific to points with three coordinates. If `ignore_z_value` is `true`, the third coordinate is not indexed but is still stored in the _source field. If `ignore_z_value` is `false`, an exception is thrown.
116-
[`null_value`]({{site.url}}{{site.baseurl}}/opensearch/supported-field-types/index#null-value) | A value to be used in place of `null`. Must be of the same type as the field. If this parameter is not specified, the field is treated as missing when its value is `null`. Default is `null`.
116+
[`null_value`]({{site.url}}{{site.baseurl}}/opensearch/supported-field-types/index#null-value) | A value to be used in place of `null`. Must be of the same type as the field. If this parameter is not specified, the field is treated as missing when its value is `null`. Default is `null`.
117+
118+
## Derived source
119+
120+
When an index uses [derived source]({{site.url}}{{site.baseurl}}/field-types/metadata-fields/source/#derived-source), OpenSearch normalizes geopoint values to a consistent latitude/longitude object format during source reconstruction, regardless of the original input format. OpenSearch may also sort multi-value geopoint fields, and precision loss can occur during the conversion process.
121+
122+
Create an index that enables derived source and configures a `geo_point` field:
123+
124+
```json
125+
PUT sample-index1
126+
{
127+
"settings": {
128+
"index": {
129+
"derived_source": {
130+
"enabled": true
131+
}
132+
}
133+
},
134+
"mappings": {
135+
"properties": {
136+
"geo_point": {
137+
"type": "geo_point"
138+
}
139+
}
140+
}
141+
}
142+
```
143+
144+
Index a document with a geohash format into the index:
145+
146+
```json
147+
PUT sample-index1/_doc/1
148+
{
149+
"geo_point": "txhxegj0uyp3"
150+
}
151+
```
152+
153+
After OpenSearch reconstructs `_source`, the derived `_source` is as follows:
154+
155+
```json
156+
{
157+
"geo_point": {"lat": 40.71, "lon": 74.00}
158+
}
159+
```
160+
161+
Index another document with a Well-Known Text format into the index:
162+
163+
```json
164+
PUT sample-index1/_doc/2
165+
{
166+
"geo_point": "POINT (74.00 40.71)"
167+
}
168+
```
169+
170+
After OpenSearch reconstructs `_source`, the derived `_source` is as follows:
171+
172+
```json
173+
{
174+
"geo_point": {"lat": 40.71, "lon": 74.00}
175+
}
176+
```
177+
178+
Index a document with multiple geopoints into the index:
179+
180+
```json
181+
PUT sample-index1/_doc/3
182+
{
183+
"geo_point": [
184+
{"lat": 75.98, "lon": 40.34},
185+
{"lat": -90, "lon": -80}
186+
]
187+
}
188+
```
189+
190+
After OpenSearch reconstructs `_source`, the derived `_source` shows sorted values with potential precision changes:
191+
192+
```json
193+
{
194+
"geo_point": [
195+
{
196+
"lat": -90.0,
197+
"lon": -80.00000000931323
198+
},
199+
{
200+
"lat": 75.97999997902662,
201+
"lon": 40.339999962598085
202+
}
203+
]
204+
}
205+
```

_mappings/supported-field-types/ip.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,45 @@ Parameter | Description
120120
[`null_value`]({{site.url}}{{site.baseurl}}/opensearch/supported-field-types/index#null-value) | A value to be used in place of `null`. Must be of the same type as the field. If this parameter is not specified, the field is treated as missing when its value is `null`. Default is `null`.
121121
`store` | A Boolean value that specifies whether the field value should be stored and can be retrieved separately from the _source field. Default is `false`.
122122

123+
## Derived source
123124

125+
When an index uses [derived source]({{site.url}}{{site.baseurl}}/field-types/metadata-fields/source/#derived-source), OpenSearch may sort IP address values and remove duplicates in multi-value IP fields during source reconstruction.
126+
127+
Create an index that enables derived source and configures an `ip` field:
128+
129+
```json
130+
PUT sample-index1
131+
{
132+
"settings": {
133+
"index": {
134+
"derived_source": {
135+
"enabled": true
136+
}
137+
}
138+
},
139+
"mappings": {
140+
"properties": {
141+
"ip": {
142+
"type": "ip"
143+
}
144+
}
145+
}
146+
}
147+
```
148+
149+
Index a document with multiple IP addresses, including duplicates, into the index:
150+
151+
```json
152+
PUT sample-index1/_doc/1
153+
{
154+
"ip": ["10.16.0.1", "192.168.0.1", "10.16.0.1", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"]
155+
}
156+
```
157+
158+
After OpenSearch reconstructs `_source`, the derived `_source` removes duplicates and sorts the values:
159+
160+
```json
161+
{
162+
"ip": ["10.16.0.1", "192.168.0.1", "2001:0db8:85a3:0000:0000:8a2e:0370:7334"]
163+
}
164+
```

0 commit comments

Comments
 (0)