Query Rule, Promote a Result Consequence, Duplication

We are testing Query Rules, with a consequence of “Promote a Result”… You can select a result to promote, and this works just fine.

We also utilize the Distinct feature to de-duplicate results based on a parent object identifier.

In testing, we have discovered that Distinct has no affect… You will always have your promoted result, and if the search term yields the same result as your promoted results, you see the result twice.

Is this a known issue? Are there any work arounds?


I’m Dorian, software engineer at Algolia and I’m going to help you solve your problem as best I can.

If I understand your problem correctly, when using the distinct feature with query rules you still see a duplicate result between the distinct search results and the promoted result.

Yes, unfortunately, it is a known issue to us that query rules do not play along well with distinct.

As a workaround, I would create a new index with deduplicated results manually and apply query rules on that index. What do you think of this proposition?

I hope this can help you and don’t hesitate to ask further questions.


This really isn’t a solution - we need to manually merchandise the top products in a collection. If this is a known issue and raised in July then when can we expect a fix please?


We’re also using Query Rules for the same reason as Trevor (manually merchandising of collections). I’ve seen scattered replies from various Algolia devs and reps stating that this is a known issue.

Are there any plans on fixing this and if so when? Your customers need to know in order to plan. Even if the answer is “Never”, if we know that its not getting fix we can maybe hack something together but I wont waste my time if its going to fixed on the platform itself.

As of right now, Im manually removing duplicates introduced by the Pinned Products but this will mess with the number of hits algolia is saying are returned which, at least in theory, could break pagination. Not an ideal solution.

Hi there,

To answer the posts above and in case someone finds this thread, here is a quick update from Algolia’s side: we are evaluating the possibility to handle the use case “distinct + promote result”, but it comes with a few challenges regarding performances and distinct values higher than 1. I will post a new update here if we move forward with a fix.

In the meantime, if you need a workaround, you can use the following solution:

  1. Promote one or more objectIDs in your Query Rule as you normally would
  2. For the promoted items, manually get the values they have in the attribute used as attributeForDistinct
  3. Add another consequence in the Query Rule (add query params), with a negative filter on this attribute, e.g. {"filters": "NOT attribute:value AND NOT attribute:otherValue"}. With this addition, you make sure that variations of the promoted products will be exluded form the results

Note that for point 3 you need to make sure that the attribute is set as an attributesForFaceting (and if you don’t use it anywhere else, it can be set as filterOnly to optimize performances).

Edit: adding more details to make the example clearer.

Let’s say you have 2 products, both with variations:

{ "objectID": "productX_1", "name": "good product", "parentID": "productX" }
{ "objectID": "productX_2", "name": "good product", "parentID": "productX" }
{ "objectID": "productY_1", "name": "other product", "parentID": "productY" }
{ "objectID": "productY_2", "name": "other product", "parentID": "productY" }

In your settings, you have parentID set for both distinct and faceting:

{ "attributeForDistinct": "parentID", "attributesForFaceting": ["parentID"] }

Then to promote those 2 products and avoid duplicates, your query rule would look like this:

1 Like