Hi,
I have a car booking system using Elasticsearch, and because of business rules, some cars are not available for booking requests during week ends.
Here is an excerpt of our mapping:
{
"car":{
"properties":{
"pickup_location":{
"type":"string"
},
"dropoff_location":{
"type":"string"
},
"type":{
"type":"string"
},
"passengers":{
"type":"integer"
},
"available_from": {
"type": "date"
},
"available_to": {
"type": "date"
},
"closing_day": {
"type": "integer"
},
"closing_time": {
"type": "integer"
},
"reopening_day": {
"type": "integer"
},
"reopening_time": {
"type": "integer"
}
}
}
}
Cars can be made unavailable a certain day (closing_day, usually friday or saturday), at a given time (closing_time, anytime between 8am to 9pm). And they "reopen" booking another day, usually sunday, at a given time (reopening_time).
Actually we have some logic in our app to display an "unavailable" message when the current time was between the closing and reopening time.
But now we'd like to filter out these cars when between closing and reopening time, and not display them at all.
I've looked at a few solution, such as adding date ranges for all the week ends, and combining "must_not" and "range" filters. Or updating our indices on a regular basis and removing the "closed" cars. But I feel like these solution are not really good.
Do you have any advice? Of course, I can change my mapping, if that's needed.
Thanks a lot.