MadMatt
MadMatt

Reputation: 119

Algolia sorting only ASC or DESC not both

I'm bit confused with Algolia settings releated to sorting, specifically in the dashboard I created new replicas, products_price_asc & products_price_desc. Then I come to the ranking formula and added a "price" attribute to the sorting.

However, it allows me to pick up the price attribute only once, so as to specify the sorting order of the price.

So the result is, that I have a dropdown menu with 2 options (price order ASC and DESC), but only one of them works correctly.

It's my first day with Algolia, so maybe I've missed something, but if anyone can explain me, how to implement this, I'll be happy.

Thanks in advance.

Upvotes: 0

Views: 845

Answers (1)

pixelastic
pixelastic

Reputation: 5278

Creating replicas for sorting is the right first step: you need one replica per sorting order (in your case, one for sorting by price DESC, and one for sorting by price ASC).

But you need to update the Ranking Formula on the replicas themselves, not on the main index.

So, on products_asc, you should set this: Custom ranking for products_asc

And on products_desc, you should set this: enter image description here

Now, when you need to order results by ascending price, you should target the products_asc index for your search. When ordering by price descending, it will be products_desc.

Upvotes: 3

Related Questions