hi guys, i’m looking at a potential of using types...
# community-help
s
hi guys, i’m looking at a potential of using typesense but had a question about how to handle commerce applications where you might have a sale price active between 2 dates… how might you approach that using typesense. to complicate matters - often the sale price triggers no events at the time of a product going on sale - its set up in advanced based on dates, which somewhat limits the possibility of updating the index at the start and end of the sale period
k
👋 Are you saying that the price field of the document will be different between a given set of dates (sale duration)?
s
well, the price of the product would be different, so that could be that it uses a single price field - but that would require updating it at the start and end of the sale period right?
k
Can this be done during display? Store a "sale_price" field, "sale_start" and "sale_end" dates. Then during display you can check if current date falls between start and end dates and display price accordingly.
s
the problem with that is when it comes to filtering isnt it?
k
What type of filtering you would like to do?
I presume within those dates, the filtering queries should hit the sale price field rather than regular price field.
s
eg show all products less then £5
k
Got it.
It seems to me like any other data store might have the same issue. One way to do this will be to run a cron at midnight everyday to do an update to prices for all the records that are going to either start a sale or end a sale.
s
indeed - its something we have with other search solutions too 🙂
currently our possible solutions involve yea having a limitation that we can only do day based sales - eg not possible to have a sale that is in operation for a short period (flash sales)
k
To do this within a search engine, that engine need to support some kind of dynamic field selection support using a specific condition, like date in this example. But a very interesting use case!
Good point regarding flash sales.
s
i think elasticsearch can handle it with function scoring - although ive not dug too deeply in to it
k
Will need something like:
Copy code
filter_by=field_select(start_date, end_date, now(), sale_price, regular_price):<5
s
yup, that would be lovely 😛
k
where
field_select
is a special expression for resolving the actual field based on the dates inside.
We do have an issue open to support expressions in filter (https://github.com/typesense/typesense/issues/405), this can be another use case for it.
s
yup, would be fantastic - as currently i dont see a good way to handle flash sales in pretty much any search solution
k
Can you add this use case to that issue also please? We will prioritize it.
s
will do, cheers
👍 1
commented on the ticket with the use case let me know if it makes sense
k
Looks perfect. 👍