Guides / Algolia recommend

Refine Recommendations with Rules

Recommend Rules are a beta feature. To get access, contact your Customer Success Manager or reach out to Algolia support.

With Recommend Rules, you can optimize your recommendations towards your business goals without changing code. Rules let you tweak recommendations generated by the machine learning models and shape your user experience dynamically.

Example use cases for Recommend Rules include:

  • Ensure that you only show related products from the same category as the viewed product.
  • Ensure that you don’t show recommendations for out-of-stock products.
  • Recommend a newly launched product first by pinning it to the first position.
  • For all products from a specific category, pin items to the top of the recommendations. For example, for all “hair” products, recommend all “shampoo” products first.

How Recommend Rules work

You can apply Recommend Rules to an existing recommendation scenario. A recommendation scenario is a combination of an Algolia index and a trained Recommend model.

You can apply up to 10,000 rules per recommendation scenario.

Rules have conditions and consequences. When the condition (if) is met, the consequence (then) is applied to the recommendation scenario.

Add Rules to a recommendation scenario

To add new Recommend Rules, follow these steps:

  1. Go to the Recommend Rules section of the Algolia dashboard and select the model, to which you want to apply Rules.

    Select the trained Recommend model to which you want to apply recommendations

  2. Click Add new Rule and specify the Conditions, when the Rule applies.

    Specify the conditions when a Recommend Rule applies

    Recommend supports these conditions:

    • Any item is a source item. The rule applies to all recommendations.
    • Specific item is viewed. The rule applies when a specific item (identified by its objectID) is viewed.
    • Subset of source items. The rule applies to items that match a filter.
  3. Optional: enter a label for a Context, that you defined in your application

    Provide a context in which the Rules applies

    Contexts act as additional constraints for rules. Common use cases for Rules contexts are distinguishing users by device type, language preference, or country. For an example of how you can define a context, see Identifying your user’s device.

  4. Specify the Consequences to determine what actions are applied to the recommendations, when the conditions are met.

    Specify which actions or consequences should apply when the conditions are met

    Recommend supports these consequences:

    • Pin items. The rule places a recommendation at a specific position.
    • Hide items. The rule excludes items from the recommendation.
    • Boost items. The rule places items higher up within recommendations.
    • Bury items. The rule places items lower down within recommendations
    • Filter items. The rule only shows recommendations that match the specified filter criteria.

    When you select Filter items as a consequence, you can select same as viewed items to let the filter criteria match to the same value as the viewed item:

    Select the same as viewed filter criteria to match the filtered attribute to the viewed item

    For example, if you want to only show book recommendations of the same genre as the viewed item, you can set “Genre” > “sameAsViewedItem” to only recommend books from the same genre as the viewed item.

  5. Optional: add a description for you and your team.

Did you find this page helpful?