问题
I have a products index that displays filtered results on category pages.
- For a given category, any amount of products may be flagged as featured, meaning it displays first.
- When products are displayed for a category, only one featured product should show at a time (at random from the available products flagged as featured)
- Additionally, a product should not be flagged as featured if it has date range fields and the current date is not within the range
So, my index might look something like: https://gist.github.com/1a0327d8a321dc6627e197b94f4209c9
A solution to 1. has been posted here: https://stackoverflow.com/a/40922535 using optional filters, currently in private beta: https://www.algolia.com/doc/advanced/optional-filters-scoring/. At query time I could do optionalFacetFilters: ["featuredIn.category:category1"]
Update: I've since been told by Algolia reps that this feature is has a large performance cost, and therefor is only really viable for enterprise customers.
However, I'm at a loss as to how to pull of 2. and 3..
Any guidance is greatly appreciated!
来源:https://stackoverflow.com/questions/41166479/complex-featured-product-model-using-query-time-ranking-optional-filters