Skip to content

Instantly share code, notes, and snippets.

@felixbarny
Created August 25, 2021 13:04
Show Gist options
  • Save felixbarny/1f6ef39321849d7dd3889c5998e02a21 to your computer and use it in GitHub Desktop.
Save felixbarny/1f6ef39321849d7dd3889c5998e02a21 to your computer and use it in GitHub Desktop.
Flattened and runtime field test
PUT test
{
"mappings": {
"dynamic": "runtime",
"properties": {
"service": {
"type": "object",
"properties": {
"name": {
"type": "keyword"
}
}
},
"labels": {
"type": "flattened"
}
}
}
}
POST test/_doc
{
"labels": {
"foo": "bar"
},
"foo": "bar"
}
# no mapping conflicts
POST test/_doc
{
"labels": {
"foo.bar": "baz"
},
"foo": {
"bar": "baz"
}
}
# all searches return the expected results
POST test/_search?q=foo:bar
POST test/_search?q=foo.bar:baz
POST test/_search?q=labels.foo:bar
POST test/_search?q=labels.foo.bar:baz
POST test/_doc
{
"service.name": "foo"
}
# fails with
# object mapping for [service] tried to parse field [service] as object, but found a concrete value
POST test/_doc
{
"service": "foo"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment