Is there any way to access an array of date_range in a painless script filter?
My mapping for the "blocked_dates" field is as follows:
"blocked_dates": {
"type": "date_range",
"format": "strict_date"
},
Data looks like this:
"blocked_dates": [
{
"gte": "2019-07-12",
"lte": "2019-07-14"
},
{
"gte": "2019-07-16",
"lte": "2019-07-18"
}
],
I am using Amazon ElasticSearch v6.7 so I cannot use params._source in a script filter and if I try and access it via doc then I get an illegal_argument_exception.
"blocked_dates = doc['blocked_dates'].value; ",
" ^---- HERE"
Fielddata is not supported on field [blocked_dates] of type [date_range]
I have a complex booking window requirement that checks if the chosen move-in and move-out date is within x days of another booking (blocked date) and this has to be done in a script.
I could do something hacky like store a copy of the array of date_range as a comma delimited (ie "2019-07-20,2019-09-12") string array. Then grab the string array from the painless script filter and parse the dates out of them.
But that is my last resort.