Skip to content

[8.19] Make flattened synthetic source concatenate object keys on scalar/object mismatch (#129600) #129793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/changelog/129600.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pr: 129600
summary: Make flattened synthetic source concatenate object keys on scalar/object
mismatch
area: Mapping
type: bug
issues:
- 122936
35 changes: 35 additions & 0 deletions docs/reference/mapping/types/flattened.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,38 @@ Will become (note the nested objects instead of the "flattened" array):
}
----
// TEST[s/^/{"_source":/ s/\n$/}/]

Flattened fields allow for a key to contain both an object and a scalar value.
For example, consider the following flattened field `flattened`:
[source,console-result]
----
{
"flattened": {
"foo.bar": "10",
"foo": {
"bar": {
"baz": "20"
}
}
}
}
----
// TEST[skip:backporting-from-new-docs]

Because `"foo.bar": "10"` is implicitly equivalent to `"foo": { "bar": "10" }`,
`"bar"` has both a scalar value `"10"`, and an object value of `{ "baz": "20" }`.

With synthetic source, to produce a valid JSON output, objects with such fields will appear differently in `_source`.
For example, if the field is defined in an index configured with synthetic source, the value of `_source` would be:
[source,console-result]
----
{
"flattened": {
"foo": {
"bar": "10",
"bar.baz": "20"
}
}
}
----
// TEST[skip:backporting-from-new-docs]
Loading