File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
docs/reference/elasticsearch/mapping-reference Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -364,3 +364,42 @@ Will become (note the nested objects instead of the "flattened" array):
364364 }
365365}
366366```
367+
368+ Flattened fields allow for a duplicate key to contain both an object and a scalar value.
369+ For example, consider the following flattened field ` flattened ` :
370+
371+ ``` console-result
372+ {
373+ "flattened": {
374+ "foo.bar": "10",
375+ "foo": {
376+ "bar": {
377+ "baz": "20"
378+ }
379+ }
380+ }
381+ }
382+ ```
383+
384+ Because ` "foo.bar": "10" ` is implicitly equivalent to ` "foo": { "bar": "10" } ` ,
385+ ` "bar" ` has both a scalar value ` "10" ` , and an object value of ` { "baz": "20" } ` .
386+
387+ With synthetic source, objects with such duplicate fields will appear
388+ differently in ` _source ` . For example, if the above field has synthetic
389+ source enabled, the value of ` _source ` would be:
390+
391+ ``` console-result
392+ {
393+ "flattened": {
394+ "foo": {
395+ "bar": "10",
396+ "bar.baz": "20"
397+ }
398+ }
399+ }
400+ ```
401+
402+ This is because, when constructing the source, the key ` "foo.bar" ` is eagerly expanding into the key ` "foo" ` with an object value.
403+ Then ` "bar" ` is added to the object with the scalar value of ` "10" ` . Then, because another
404+ ` "bar" ` cannot be added with an object value, ` "bar" ` and ` "baz" ` are collapsed
405+ in the flat key ` "bar.baz" ` with a scalar value of ` "20" `
You can’t perform that action at this time.
0 commit comments