AI OnAI Off
You could try using BuildFilter for category, something like this:
var categoryFilter = SearchClient.Instance.BuildFilter<IndexedDownload>();
if (filterQuery.Categories != null && filterQuery.Categories.Any())
{
foreach (var item in filterQuery.Categories)
{
categoryFilter = categoryFilter.OrFilter(f => f.Category.In(new List<string> { item }, true));
}
query.Filter(categoryFilter);
}
The issue isn't with the filter of categories, this already seems to work, its around the FileTypes. What I am trying to do is:
"Is in Category OR Category OR Category AND is in File Type OR File Type OR File Type"
Seems my code just nests everything under a OR with no AND
The do similar for FileTypes:
var fileTypeFilter = SearchClient.Instance.BuildFilter<IndexedDownload>();
if (filterQuery.FileTypes != null && filterQuery.FileTypes.Any())
{
foreach (var item in filterQuery.FileTypes)
{
fileTypeFilter = fileTypeFilter.OrFilter(f => f.FileType.Match(item));
}
query.Filter(fileTypeFilter);
}
I'm trying to filter my indexed items by categories (Or) and then by filetype, so "And match this filetype, or this filetype" etc
My Data structure look like this:
I have my current query set out at this:
If I try and change the FileTypes filter too:
It brings back file types it shouldn't, I am guessing because everything is wrapped up in an overall OR filter its bringing everything back based on those matches, running through Fiddler confirms this I think:
So what would be the way to get results based on being in one of the categories and in one of the file types too