Gravatar for koradav@deshaw.com

Question by vrkorada, Jul 8, 2014 8:16 AM

Top results are appearing even if I exclude the collection. Is this expected?

This is slightly confusing as the results still appears on the top even if the user excludes the collection to narrow the results. Is there any way to have top results associated with some keywords, but show them only when the collection is not excluded.

Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Jul 8, 2014 9:25 AM

How is the collection excluded?

Gravatar for koradav@deshaw.com

Comment by vrkorada, Jul 8, 2014 9:27 AM

Manually by clicking on the icon that you get on mouse hover on a given collection (icon - crossed circle ). Even if you exclude all collections, you still see the top results.

2 Replies
Gravatar for cbolduc@coveo.com

Answer by Carl Bolduc, Jul 28, 2014 8:58 AM

Currently, it is not possible to exclude a top result from the result list. We already have an enhancement request logged in to disable top results on a query.

For now, you can do something like this to filter the top results, assuming that they are not in the collection that you are querying:

Coveo.$('#search').on('preprocessResults', function(e, args){
    args.results.results = _.filter(args.results.results, function (result, i) { return result.raw.syscollection == 'MyCollectionName'; });
}
Gravatar for koradav@deshaw.com

Comment by vrkorada, Jul 28, 2014 9:13 AM

Thanks for the solution. Instead of jQuery solution, can I use scripts for pre/post processing the results (it seems the above script also uses preprocessing). I am already using script to exclude few collections from the facet in 'CoveoSearch.ascx' if there are any events that I can use in this same ascx file to get the same result, that would be easy for me to implement.

Gravatar for cbolduc@coveo.com

Comment by Carl Bolduc, Jul 28, 2014 11:22 AM

There is the CheckResultVisibility Event where you could do something like that:

args.Display = !args.Result.IsTopResult
Gravatar for yrivardmulrooney@coveo.com

Answer by Yannis Rivard-Mulrooney, Jul 25, 2014 12:18 PM

You can exclude these top results by expanding the "Advanced Search" section and unchecking the collection. Sadly, as of now, excluding this by facets will not work since selecting/excluding values from them only adds to the query text (which is not the filter we use in this case).

Gravatar for koradav@deshaw.com

Comment by vrkorada, Jul 28, 2014 3:07 AM

This will not work as it requires explicit actions with multiple clicks from users. When users are able exclude some collections from the facet, it is not ideal to ask them to exclude the collection from advanced search again for getting proper top results. If there any event that triggers the filtering of facet and then to apply same filter for the top results?

Ask a question