Hi!
I have been trying to model an ES application to search for hotels.
An hotel contains a name, descriptions in several languages, tags and GPS position, making it easy to search by description, filter by tags or geo locate.
One of the important points is pagination and ordering. The user may want the results to be ordered by relevance, or by price.
The difficult part is when it comes to pricing. An user would search for a time range with a maximum amount of money in mind, like 100 per night. Basically, there is a price per each night in the calendar (that is pre-calculated based on some user configuration), so I would have a calendar like structure, which each price, being -1 a non available date.
{
"20190617": 90,
"20190618": 110,
"20190619", -1,
...
}
So I believe that it would be possible to do a scripted search where the sum of the required date fields, is less than "desired price per night" * days. But then the problem is to garbage collect the days that are in the past in an efficient way.
I have read about the "index per time frame" approach, but I am not sure if I get it, or it is just not suitable for my problem. If I create a separate index per month, it would be very easy to delete old data, but how does it combine with the other search parameters? If I have to do two separate queries, how do I work out pagination?
Another approach would be to use other database for the pricing thing. Basically I would do the pricing, tag and geo search in Redis, getting a short list of IDs (hundreds) to pass to ES so it can filter by full text search, and getting paginated results. If ordering by price, the order given by Redis should be respected, otherwise whatever relevance order coming from ES would be good.
What do you think?