hello , I have this runtime -
GET my-index-000006-test/_search
{
"runtime_mappings": {
"day_of_week": {
"type": "keyword",
"script": {
"source": "emit(doc['timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
}
}
},
"fields" : ["day_of_week"]
}
Its gives the day of the week from the timestamp -
{
"_index": "my-index-000006-test",
"_id": "tUF9rIkB6LNnmdzdzkzz",
"_score": 1,
"_source": {
"title": "three",
"timestamp": "2021-01-04"
},
"fields": {
"day_of_week": [
"Monday"
]
}
},
does have any how to get the Month of the year ? I tryed like that -
GET my-index-000006-test/_search
{
"runtime_mappings": {
"month_of_year": {
"type": "keyword",
"script": {
"source": "emit(doc['timestamp'].value.getMonth()"
}
}
},
"fields" : ["month_of_year"]
}
but didnt work