There may be scenarios in which you would like to exclude a specific product from the returned recommendations. For example:
- The user has a product in the cart.
- The user has purchased a product previously.
Algolia Recommend doesn't automatically exclude these products based on the contents of a user's cart or their purchase history. Instead, you can pass a filter as a query parameter with the Recommend request to exclude specific records.
For example, let's say the user already has Product A (objectID: "123") in their cart. If you're using React InstantSearch to send your Recommend requests, you can pass a filter through queryParameters:
<RelatedProducts
objectIDs={["555"]}
limit={5}
queryParameters={{
filters: 'NOT objectID:"123"',
}}
/>
If the user has multiple products in their cart, you can dynamically construct the filter to exclude each of those records.