GET blogs/_search
{
"runtime_mappings": {
"publish_hour": {
"type": "long",
"script": {
"source": "emit(doc['publish_date'].value.hour)"
}
}
},
"query": {
"bool": {
"filter": [
{
"range": {
"publish_date": {
"gte": "2018-01-01",
"lte": "2018-12-31"
}
}
},
{
"bool": {
"should": [
{
"range": {
"publish_hour": {
"gte": 0,
"lt": 6
}
}
},
{
"range": {
"publish_hour": {
"gte": 23,
"lt": 24
}
}
}
]
}
}
]
}
},
"_source": false,
"fields": [
"publish_date",
"publish_hour"
]
}
Created
December 15, 2021 03:10
-
-
Save ijokarumawak/7fd8755fb7e3d53e8f197bb71f2881a4 to your computer and use it in GitHub Desktop.
A runtime field example at query time.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment