I'm trying to figure out how to perform a Find query that excludes results that have a certain category. This is proving much more difficult than I initially thought. From what I can see, the filters are all for the inclusion of results.
I have a block that finds article content. I'd like to apply a property to say Exclude Category, and exclude all content that has that particluar category from the search results. For instance "Exclude From Home Page".
Can anyone point me in the right direction for this please?
Maybe this off the top of my head if doing a non match on multiple categories
public static ITypeSearch<T> DoesNotMatchCategories<T>(this ITypeSearch<T> search, CategoryList categoryList) where T : ICategorizable
var requiredFilter = new FilterBuilder<T>(search.Client);
foreach (var category in categoryList)
requiredFilter = requiredFilter.And(x => !x.Category.Match(category));
Scott Thank you.. I'll try that now. I thought because Match returned a DelegateFilterBuilder I couldn't negate it.
Unfortunately that doesn't seem to be working. Is there a way to output the search query being sent to Find? I wonder if sorting through that would help.
Sorry, this is a steady stream of conciousness. You logic works. I stripped out most of the existing logic on the block and excludes the article as hoped. It seems there is a conflict with other logic on the page and I'm trying to troubleshoot what it's colliding with.
You helped me a ton, I think I just needed to walk away and drink a coffee. I didn't chain the call properly when I tried to implement it, but I did when I stripped everything away. Phew, mission accopmlished. Thank you again.