Charles de Dreuille
Charles de Dreuille

Reputation: 333

Sort results by relevance without filtering in Algolia

Is there a way to sort results in Algolia by relevance instead of filtering them? In our case we have quite a few important attributes but we only have around 700 products so many times the search using facets end up with few or no results.

To avoid this, we are looking for a solution to reorder the list by relevance to show the best results on top while allowing users to still see the other less relevant results. Basically not filtering products, but just reorder them by relevance based on a combination of attributes we set.

Thanks

Upvotes: 0

Views: 484

Answers (1)

Sarah Dayan
Sarah Dayan

Reputation: 468

When setting filters leads you to few or no results, and you'd like to avoid that by still showing less relevant results, two solutions come to mind:

  1. Use optionalFilters instead of filters. You get the same behavior as with filtering, but the Algolia API also returns results that don't match the filters and ranks them lower. This is the ideal solution, as it takes a single API round trip.
  2. Perform a second search without filters when the first search returns fewer records than a threshold of your choice. This is a more manual approach and takes up to two API calls.

Upvotes: 1

Related Questions