Gravatar for

Question by Dan Sinclair, Dec 12, 2018 3:32 PM

queryBuilder.enableDuplicateFiltering not applying to searches

Using Coveo for Sitecore 4.1, we are trying to enable the `enableDuplicateFiltering` feature on any queries on a page.

I have added the following script to the page.

    function () {
        Coveo.$('.CoveoSearchInterface').on('buildingQuery', function(e, args)         {
            args.queryBuilder.enableDuplicateFiltering = true;

I have confirmed that it is executing whenever a query is issued (by setting a breakpoint). However, when I inspect the outbound request to the service (`/coveo/rest/v2`), the `enableDuplicateFiltering` parameter is set to false.

2 Replies
Gravatar for

Answer by Dan Sinclair, Dec 12, 2018 4:38 PM

@François Lachance-Guillemette showed me the way:

This property needs to be set on the dataset of the search interface on initial load (not as part of a `buildingQuery` event handler):

document.addEventListener('DOMContentLoaded', function () {
    $.each($('.CoveoSearchInterface'), function(i, searchInterface) {
        searchInterface.dataset.enableDuplicateFiltering = true;
Gravatar for

Answer by François Lachance-Guillemette, Dec 12, 2018 3:56 PM

First, let me take a step back. Why do you want to enable this feature?

This is most likely a "smell" that there is something wrong with your indexed documents, and I would instead try to fix your issue at the indexing level.


Now as for your actual question:

If you check the QueryBuilder object, there is no `enableDuplicateFiltering` attribute fronted on this object, so it will not be taken into account when building the query.

The SearchInterface has an attribute for it though, so in this case, it has to be configured on the Search Interface level. See the notes written in the documentation link for limitations of this attribute.

Coveo for Sitecore Hive does not front it OOTB because it was wrongly used to fix indexing issues. You would have to insert this `data-` attribute directly in your markup, or by setting is programmatically like the following:

document.getElementById("YOUR_SEARCH_ID").dataset.enableDuplicateFiltering = true;
Gravatar for

Comment by Dan Sinclair, Dec 12, 2018 4:17 PM

To address your first question: I agree; I would much rather fix it at the indexing level. Unfortunately, it's another team that's been tasked with that and they have asked me to implement `enableDuplicateFiltering` in the short term as a stop-gap fix.

I see what you mean in the reference you posted about the QueryBuilder that there is no `enableDuplicateFiltering` property, but it's definitely there when I inspect the QueryBuilder object at runtime:

Also, I've seen it referenced in other solutions and reference documentation:


Finally, I can't find the `enableDuplicateFiltering` property on the dataset object for my search interface object, either:

I tried setting it anyway, but the request still said `enableDuplicateFiltering: false`.

Ask a question