I am currently creating a service using Episerver Find. I have managed to get everything working apart from the filtering of Categories. From the API that is recieved in the solution, we get a multiple lists of Categories that have been selected inside a category list.
E.g.
Categories: [ ["Category 1","Category 2" ], ["Category 11","Category 12" ] ]
After this, when searching using Find, I need to check for items that have "Category 1" OR "Category 2" AND "Category 11" OR "Category 12". If none of the items have these categories assigned to them, or as an example only have Category 1 assigned and nothing from the second list, no results should be returned.
I can not seem to find a way to do this. I Have tried a Filter Builder using the OR method and then passing that into the the Search.Filter() method but that seems to get changed to an OR filter instead of an AND filter. Here is the code of that just in case I there is a mistake
public static ITypeSearch MatchCategories( this ITypeSearch search, IList categoryList) { var categoryFilter = SearchClient.Instance.BuildFilter(); foreach (var category in categoryList) { categoryFilter = categoryFilter.Or(x => x.RelatedCourses.MatchItem(p => p.CourseCategories.Match(category))); } return search.Filter(categoryFilter); }