Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
2.11
Describe the issue:
I seem to be able to reference keys from a flat_object field when using Painless inline within script_fields, but unable to access the same keys when using Painless inline within a filter script.I am attempting to avoid mapping explosion since I have dynamic keys, but also require the ability to filter on the values stored as types other than string, so the hope is to access via Painless and perform comparisons within the scripts.
The following works (accessing keys within script fields):
GET /index/_search
{
"script_fields": {
"test1": {
"script": {
"lang": "painless",
"source": "params._source.flat_object_test.key1"
}
}
}
}
The following do not work (for boolean key1
within the flat_object
):
GET /index/_search
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"lang": "painless",
"source": "params._source.flat_object_test.key1"
}
}
}
}
}
}
GET /index/_search
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"lang": "painless",
"source": "doc['flat_object_test.key1'].value"
}
}
}
}
}
}
GET /index/_search
{
"query": {
"bool": {
"filter": {
"script": {
"script": {
"lang": "painless",
"source": """
def fo = doc['flat_object_test'];
return fo['key1'];
"""
}
}
}
}
}
}
Configuration:
{
"mappings": {
"flat_object_test": {
"type": "flat_object"
}
}
}
Any help appreciated!