Try our conversational search powered by Generative AI!

Category filter not working

Vote:
 

I'm using the following code to retrieve pages based on a list of categories:

var categoryFilter = SearchClient.Instance.BuildFilter<ExpertisePage>();

foreach (var categoryId in list)
{
   categoryFilter.Or(x => x.InCategory(categoryId));
}

return SearchClient.Instance.Search<ExpertisePage>()
                    .Filter(categoryFilter)
                    .OrderBy(e => e.PageName)
                    .FilterForVisitor()
                    .GetContentResult().ToList();

    

For some reason Find returns all pages of type ExpertisePage (for the current language). Seems like the filter is not applied at all.

I've tried using x => x.Match(categoryId) but result is the same.

#86024
May 12, 2014 13:42
Vote:
 

Have you tried doing categoryFilter = categoryFilter.Or(...) instead?

#86025
May 12, 2014 14:08
Vote:
 

Ah, you're right. My brain is still in weekend mode. :) Thanks, Alf! 

 

#86026
May 12, 2014 14:18
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.