0

I want to feature (move to top of results) certain products on only certain search result pages. With only a single search performed. A Custom Ranking Attribute would boost a product's ranking for all pages, instead of certain pages.

A somewhat working solution is to add an attribute like "featuredin":"[searchterm]", and move "featuredin" to top of Searchable Attributes. However, products with similar searchterm could be featured on the wrong page. example: There are products with "featuredin":"iphone", and products with "featuredin":"iphone accessories". Since searching 'iphone' in attribute 'featuredin' will also get hits on products with "featuredin":"iphone accessories", I'm getting iphone accessories featured on iphone search results.

This solution could work if there's a way to force 'true' exact match for an attribute. But I couldn't find something like that.

Thanks.

Derekz
  • 1

1 Answers1

1

There is actually a nice way to implement that behavior using "optional" facet filters (a soon to be released advanced feature - as of 2016/11/15).

An "Optional Facet Filter" is a facet filter that doesn't need to match to retrieve a result but that will - by default - make sure the hits that have the facet value are retrieved first (thanks to the filters criterion of Algolia's tie-breaking ranking formula).

This is exactly what you want: on every single page where you want some results sharing a featuredin value to be retrieved first; just query the Algolia index with the featuredin:"a value" optional facet filter.

  • make sure your featuredin attribute is part of your attributesForFacet index setting
  • at query time, query the index with index.search('', { optionalFacetFilters: ["featuredin:iphone accessories"])

You can read more on this (beta) documentation page.

redox
  • 2,269
  • 13
  • 22
  • That would work as a solution. Some followup questions: 1. ETA for optional facet filter for live? 2. The beta doc page mentioned a performance hit - what range (ms) should I be expecting? 3. In case the performance hit is substantial, is it possible to implement 'true' exact match for an attribute? future-feature perhaps? Thanks for the reply! – Derekz Nov 15 '16 at 21:51