The following two queries should return the same results:
GET iam-api-accounts/_search
{
"query": {
"bool": {
"filter": {
"script": {
"script": """
return params._source?.roles?.dance != null && params._source?.roles?.dance != false
"""
}
}
}
}
}
GET iam-api-accounts/_search
{
"runtime_mappings": {
"dance_exists": {
"type": "boolean",
"script": """
emit(params._source?.roles?.dance != null && params._source?.roles?.dance != false);
"""
}
},
"query": {
"term": {
"dance_exists": true
}
}
}
However, params._source
is always null in the first query; only the second one returns the correct results.