🔧 Maintenance Alert: World will be on Read-Only Mode on February 18th, 10:00 PM – 11:00 PM EST / 7:00 PM – 8:00 PM PST / 4:00 AM – 5:00 AM CET (Feb 19). Browsing available, but log-ins and submissions will be disabled.
AI OnAI Off
🔧 Maintenance Alert: World will be on Read-Only Mode on February 18th, 10:00 PM – 11:00 PM EST / 7:00 PM – 8:00 PM PST / 4:00 AM – 5:00 AM CET (Feb 19). Browsing available, but log-ins and submissions will be disabled.
Have you tried adding a separate property that is just IEnumerable<string>? It will make the filtering easier and you might be able to use In() or just Exists() and Match().
Hi @Steven Galton
Somethign like below could solve issue.
public static ITypeSearch MatchCategories( this ITypeSearch search, IList categoryList) { foreach (var category in categoryList) { var categoryFilter = SearchClient.Instance.BuildFilter(); foreach (var cat in category) { categoryFilter = categoryFilter.Or(x => x.RelatedCourses.MatchItem(p => p.CourseCategories.MatchContained(cat))); } search = search.Filter(categoryFilter); } return search; }
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.
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