A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More.
AI OnAI Off
A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More.
Hi Dileep,
You could probably create an empty filter that essentially does nothing and then extend that to either do something, or not, depending on if the content reference is null or not.
I.E. -
var referenceFilter = multisearch.BuildFilter<ContentArticlePage>();
// I'm assuming you have access to the 'other' content reference you mentioned
if (contentReferenceItem != null)
{
referenceFilter = referenceFilter.And(x => x.Field.Match(contentReferenceItem));
}
// Then add the filter into your existing search logic above 'FilterForVisitor()'
.Filter(referenceFilter)
Obviously, I don't know your exact code but hopefully the above will give you the gist of the idea.
Hope it helps!
- JJ
Can you do something like
query = query.Filter(x => CheckForContent(contentref) | contentref == null);
I have a search code as shown below that works fine. On the page where I show these result I have another content reference field that am displaying. I need to see if the search result contains the content reference item on the page and if so then remove it from the results.
Typically I can do a filter but the problem is that content reference can also be null so am not sure how to incorporate that null check.
foreach (var category in secondaryCategoryPages.Take(WebConstants.MaxMultiSearch))
{
multisearch = multisearch.Search<ContentArticlePage, SearchHitResult>(s => s
.FilterForVisitor()
.Skip((page - 1) * pageSize)
.Take(pageSize)
.OrderByDescending(x => x.ArticleDate)
.Select(x => ConvertFromIContent(x.ContentLink, category))
.StaticallyCacheFor(new TimeSpan(0, 5, 0)));
}