Gravatar for d.rousseau@snhu.edu

Question by drousseau99, Jun 18, 2015 10:45 AM

Querybuilder filter by item id

Using the javascript api querybuilder, is there a way to filter results to exclude a specific item id? I would like to exclude our 404 page by the item id. I can currently do it by name using the code below, but I would like to use template id in case the name of the item changes.

args.queryBuilder.constantExpression.add('<%= ToCoveoFieldName("Name") %> <> "404"');

I have tried using Id and ItemId in the place of name, with no success.

1 Reply
Gravatar for jflheureux@coveo.com

Answer by Jean-François L'Heureux, Jun 18, 2015 11:01 AM

To find which fields are available, you can look in the CES Admin Tool for your generated field set (Configuration > Fields > Field set for [SitecoreIndexName] - [MachineName]-[SitecoreInstanceName]) or in the Index Browser for the document you want to filter (Index > Index Browser).

In your case, you can use "id", "indexableitemid" or "_id" which are all indexed as ShortIDs (e.g.: 110d559fdea542ea9c1c8a5df7e70ef9).

args.queryBuilder.constantExpression.add('<%= ToCoveoFieldName("_id") %> <> "110d559fdea542ea9c1c8a5df7e70ef9"');
Gravatar for d.rousseau@snhu.edu

Comment by drousseau99, Jun 18, 2015 11:10 AM

thanks, I had tried those field names with no luck, turns out it was because I had the hyphens in my GUID. Removing those fixed it!

Ask a question