Gravatar for

Question by Matt, Jan 28, 2016 9:48 AM

Select Distinct Sitecore item?

I'm using Coveo with Sitecore, and occasionally I will have different versions of the same item listed in an index.

(ex: sitecore://database/web/itemid/{12345678-9abc-def0-1234-56789abcdef0}/language/en/version/4 & sitecore://database/web/itemid/{12345678-9abc-def0-1234-56789abcdef0}/language/en/version/5)

Is there a way I can instruct my query to do something akin to: 'SELECT DISTINCT itemid…'

So my results would show only one copy of the item?

2 Replies
Gravatar for

Answer by Sébastien Belzile, Jan 28, 2016 11:22 AM

I think your issue is linked to this bug:

Gravatar for

Comment by Matt, Feb 9, 2016 2:22 PM

This was in-fact the problem. We applied a patch provided by Sitecore support to resolve the issue.

Gravatar for

Answer by Simon, Jan 28, 2016 9:56 AM

It should actually filter by default using Coveo Search control.

If you open the browser Network Tab (f12), you should see a package sent to the index. A XHR type using a POST method.

In the Form Data of the Header (in Chrome, separate tab in Firefox) you will see the following parameters:


q is the current query, if the query box is empty, you won't see it.
aq is an advanced query.
cq is a constant query, same as aq but kept in the index cache, so NEVER use dynamic logic with that parameter.

Now that this is said, you should by default see this cq:

(@fz95xlanguagexxxxx=="en" @fz95xlatestversionxxxxx=="1")

On English pages. Are you seeing this?

Gravatar for

Comment by Jean-François L'Heureux, Jan 28, 2016 10:25 AM

If you use LINQ, you can filter in a Where clause like this:

.Where(item => item["_latestversion"] == "1")
Gravatar for

Comment by Matt, Jan 28, 2016 11:02 AM

I am seeing a CQ like that. Unfortunately all of the records are the value '1' in the field '@fz95xlatestversion30047'. I'm told there may be a flaw in SC 8.0 behind this. I'm hoping I can do something like "group by item ID, select (newest)" to work around it…

Ask a question