documentation
documentation copied to clipboard
Add guide on promoting or demoting certain documents
Briefly:
- Add an attribute
priority
to all of your documents. The value should be a number with a value from 1 to 10. - Add a custom ranking rule
desc(priority)
at the top (or somewhere close to the top) of the ranking rules list. This will sort all results bypriority
, with the highest values first (e.g. a document with priority 10 will show up at the top of the list, even if it doesn't match the query as well as documents below). - Voilà, you now have 10 different promotion levels for your documents.
Example use case: you're running a clothing e-shop and you want garments that are on sale to show up above those that are list price. Create an attribute on-sale
, and give it a value of either 0 (not on sale) or 1 (on sale), etc etc.
Similar to: https://www.algolia.com/doc/guides/managing-results/must-do/custom-ranking/how-to/boost-or-penalize-some-records/