Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Find returning Expired content

$
0
0

Episerver v11.12.0 hosted at Episerver Azure

I am using FIND to list specific blocks that I pull from a folder.  However, the search included blocks that are marked Expired.  I am using the extensions CurrentlyPublished().FilterForVisitor().ExcludeDeleted().  I have several other parameters I'm adding to the search.  Is it possible I'm loading adding them in the wrong order?

var query = SearchClient.Instance.Search<ArticlePage>();
query = query.Filter(y => y.Ancestors().Match(insightsPage.PageLink.ID.ToString()));
if (!string.IsNullOrEmpty(queryString))
{
    query = query.For(queryString, q =>
        {
            q.Query = $"*{q.Query}*";
            q.Boost = 2;
            q.DefaultOperator = EPiServer.Find.Api.Querying.Queries.BooleanOperator.And;
        });
}
var filterBuilder = SearchClient.Instance.BuildFilter<IInsightPage>().FilterOnCurrentSite()
    .CurrentlyPublished().FilterForVisitor().ExcludeDeleted();
if (categories != null && categories.Any()) {
    foreach (var category in categories)
    {
        filterBuilder = filterBuilder.And(x => x.SearchCategories().Match(category));
    }
    query = query.Filter(filterBuilder);
}
query = query.OrderBy(page => page.Heading);
var results = query.GetContentResult();

Viewing all articles
Browse latest Browse all 9076

Trending Articles