Hi,
I am facing issue while applying filter to episerver find.
I want to filter results based on condition that items found should be based on Document Class Property "HideDocumentInSearchResults" Value True/False.
If True should filter out from results, if False should be there in results.
My code is as below:
private string theQuery; //it is set as "08132.pdf"
private FilterBuilder BuildTypeFilters(string facet)
{
var filter = this.client.BuildFilter();
filter = filter.And(y => y.MatchTypeHierarchy(typeof(SiteBasePageData)) | y.MatchType(typeof(SiteBasePageData)));
filter = filter.Or(y => y.MatchTypeHierarchy(typeof(Document)) | y.MatchType(typeof(Document)));
filter = filter.And(q => !((SiteBasePageData)q).HideInSearchResult.Match(true)); //this works fine
filter = filter.And(q => !((Document)q).Name.Match("08132.pdf")); //this works fine
filter = filter.And(q => !((Document)q).HideDocumentInSearchResults.Match(true)); //this fails
return filter;
}
private IContentResult GetResult(int take = 10, int skip = 0) where T : class, IContent
{
this.theQuery = query;
var result = this.client.Search(Language.Swedish).For(this.theQuery)
.UsingSynonyms()
.InField(x => x.SearchTitle())
.InField(x => x.SearchText())
.InAllField()
.ApplyBestBets()
.CurrentlyPublished()
.PublishedInCurrentLanguage()
.Filter(this.typefilter)
.Filter(this.wherefilter)
.FilterForVisitor()
.ExcludeDeleted()
.Track()
.Skip(skip)
.Take(take)
.FilterFacet("document", x => x.MatchTypeHierarchy(typeof(Document)) | x.MatchType(typeof(Document)))
.FilterFacet("news", x => x.MatchTypeHierarchy(typeof(NewsPageType)) | x.MatchType(typeof(NewsPageType)))
.StaticallyCacheFor(new TimeSpan(0, 0, 0,CacheSeconds))
.GetContentResult(CacheSeconds)
;
return result;
}
Thanks.
BR/Rajesh K