Filter is not working in ITypeSearch<GenericMedia>

Vote:
 

Hi Team,

I have been facing an issue with filters in find.

Below is code:

search = SearchClient.Instance.Search<GenericMedia>(Language.English).FilterForVisitor();

var searchFilter = SearchClient.Instance.BuildFilter<GenericMedia>();

if (category.Categories != null) // Categories are IList<ContentReference> type
{
        foreach (var item in category.Categories)
       {
           searchFilter = searchFilter.Or(p => p.Categories.MatchContained(a => a.ID, item.ID));
       }
}

search = search.Filter(searchFilter)

var contentResult = search.Take(10).GetContentResult();

I need to get Categories is null and mathed Categories. Above code is working when Categories is not null, but I need to return null items from find. When I check in find JSON, Categories field is not created if it is null. How to check Exist or null in find BuildFilter.

Could you someone guid me on this.

Thanks in advance.

Regards,

Narayana.

#224397
Jun 18, 2020 16:07
* 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.