Gravatar for puneetpande@gmail.com

Question by ppande, Apr 2, 2015 2:11 PM

Exclude Items that don't have presentation details in Sitecore

Hi,

On my search result page I want to remove items that do not have any presentation details on them. Where is the best place to customize this?I was thinking coveoProcessParsedRestResponse but can't figure out a way.I do want to index items that don't have presentation details. I just don't want to show them on the Search Result page.

Thanks!

2 Replies
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Apr 2, 2015 2:34 PM

Coveo for Sitecore has a filtering rule named "where the item has layout" (see Using Boosting/Filtering Rules on the Search component).

Gravatar for puneetpande@gmail.com

Comment by ppande, Apr 2, 2015 2:54 PM

is this available for the free version of Coveo for Sitecore?

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Apr 2, 2015 3:01 PM

No, this is only in the Enterprise edition but you can do the same in your search component code (ascx/cshtml file) in JavaScript (see Adding Filter and Boost Expressions Programmatically).

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Apr 2, 2015 3:01 PM

Code:

Coveo.$(function() {
    Coveo.$('#search')
    // Add a filter expression to display only items that have a layout
    .on("buildingQuery", function(e, args) {
        args.queryBuilder.constantExpression.add('<%= ToCoveoFieldName("haslayout") %> == "1"');
    })
    .coveoForSitecore('init', CoveoForSitecore.componentsOptions);
});
Gravatar for puneetpande@gmail.com

Comment by ppande, Apr 2, 2015 5:08 PM

This works. But I realize that this logic will not work because i have some custom url logic. I need to actually look into the clickUri and if it contains "someword", then don't include. How can I do a contains on clickUri in this scenario.

Thanks for your help!

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Apr 2, 2015 5:18 PM

Code:

Coveo.$(function() {
    Coveo.$('#search')
    // Add a filter expression to display only items that does not contains "someword" in their click uri
    .on("buildingQuery", function(e, args) {
        args.queryBuilder.constantExpression.add('NOT @sysclickableuri="someword"');
    })
    .coveoForSitecore('init', CoveoForSitecore.componentsOptions);
});
Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Apr 2, 2015 5:18 PM

Basically, find the field you want to filter on in the CES index browser. If it is decorated (@f…XXXXX), use ToCoveoFieldName. If not decorated, use the field name as is.

  1. Contains expression: @field="value"
  2. Exact match expression: @field=="value"
  3. Negative filter: NOT [Expression]
Gravatar for puneetpande@gmail.com

Comment by ppande, Apr 2, 2015 5:52 PM

WORKS!!! Thanks :)

Gravatar for vseguin@coveo.com

Answer by Vincent Séguin, Apr 2, 2015 2:13 PM

Hi,

Could you simply filter out items that have the field "haslayout" set to 0?

Gravatar for puneetpande@gmail.com

Comment by ppande, Apr 2, 2015 2:47 PM

Where exactly do I filter out? Which pipeline?

Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Apr 2, 2015 3:02 PM

It's not in a pipeline. It's in the search component JavaScript code. See my answer.

Ask a question