Versions 2.17:
Describe the issue:
I wanna add a dynamically generated field like description
directly into _source
instead of using script_fields
. I used an inline script within the _source
section by creating a runtime_field
, my dsl:
GET /opensearch_dashboards_sample_data_flights_pk/_search
{
"from": 0,
"size": 1000,
"_source": true,
"query": {
"bool": {
"filter": [
{ "term": { "Dest": { "value": "Venice Marco Polo Airport", "boost": 1 } } },
{ "term": { "DestWeather": { "value": "Sunny", "boost": 1 } } },
{ "regexp": { "OriginCityName": "O.*" } }
]
}
},
"runtime_mappings": {
"description": {
"type": "keyword",
"script": {
"source": "if (doc['OriginWeather'].value == 'Sunny') { return 'OK'; } else { return 'NotOK'; }"
}
}
},
"track_total_hits": true
}
But it not working, error log:
{
"error": {
"root_cause": [
{
"type": "parsing_exception",
"reason": "Unknown key for a START_OBJECT in [runtime_mappings].",
"line": 14,
"col": 23
}
],
"type": "parsing_exception",
"reason": "Unknown key for a START_OBJECT in [runtime_mappings].",
"line": 14,
"col": 23
},
"status": 400
}
I dont know what wrong with my dsl, hope someone can help me.
Thank you very much for speding time with my issue.
Configuration:
Relevant Logs or Screenshots: