0

We are using search index in our website and we want to restrict some items based on conditions. Any suggestions will help us.

2
3

As @TamerM mentioned, you can write the searchhelper which can filter the results based on content type(templates) and, you can also filter based from which location you want to search.

For e.g:
var templateGuid = Sitecore.Data.ID.Parse("{CF42D521-C709-4324-BA03-0F4765F370A6}");
var templateSearch = PredicateBuilder.True();
templateSearch = templateSearch.Or(y => y.TemplateId == templateGuid);
query = query.Where(templateSearch);

This will returns items that belongs to specific template, which is passed as parameter to searchhelper method.

0

A simpler approach, if acceptable in your case, is to simply let them get indexed but only return results that have the field 'exclude from search' as false.

You could have a common search method that does all these checks.

A great example for this is the Habitat Project on Github. Check its SearchService class under Foundation.Indexing project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.