resp = client.search(
index="sales",
size="0",
body={
"runtime_mappings": {
"date.day_of_week": {
"type": "keyword",
"script": "emit(doc['date'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))",
}
},
"aggs": {"day_of_week": {"terms": {"field": "date.day_of_week"}}},
},
)
print(resp)