Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Hide pages that have a Stop Publish date

Vote:
 

Hi,

We have a number of pages on the site that have a Stop Publish date yet these pages are still indexed by FIND. Is there anything that I can set up to detect this to prevent unwanted results when a user searches the site?

I am currently using Episerver 6 R2 - UnifiedSearch:

 

 // Add CMS Content SearchClient.Instance.Conventions.UnifiedSearchRegistry .Add(); // Start search for query var query = SearchClient.Instance.UnifiedSearchFor(Query,Language.English); //if (CurrentPage.UseAndForMultipleSearchTerms) //{ var queryStringQuery = (IQueriedSearch)query; query = queryStringQuery.WithAndAsDefaultOperator(); //} // Setup default filters (not user driven) query = query.TermsFacetFor(x => x.SearchSection); if (!string.IsNullOrEmpty(SectionFilter)) { Array QsA = SectionFilter.Split(','); foreach (var i in QsA) { query = query.OrFilter(x => x.SearchSection.Match(i.ToString())); } } query = query.Filter(x => !x.SearchSection.Match("Deleted"));//hopefully filter out any items in the Recycle bin query = query.Filter(x => x.SearchSection.Match(SearchLocation != null ? SearchLocation : "CITB")); query = query.Filter(x => x.MatchTypeHierarchy(typeof(PageTypeBase))); //query = query.Filter(x => x.MatchTypeHierarchy(typeof(TemplatePage))); query = query.Skip((PagingPage - 1) * PageSize) .Take(PageSize) .ApplyBestBets(); var hitSpec = new HitSpecification { HighlightTitle = true, HighlightExcerpt = true, ExcerptLength = 100 }; // Track user searches query = query.Track(); Results = query.GetResult(hitSpec);
#109683
Oct 13, 2014 10:34
Vote:
 

There is a FilterForVisitor() function in the EPiServer.Find.Cms namespace.  Not sure about the CMS 6 R2 version has this though. If not I guess you need to add a date filter yourself. http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-Find/8/DotNET-Client-API/Searching/Filtering/DateTime/

#109691
Oct 13, 2014 12:05
Vote:
 

Hi, thanks for this but the Filter only allows PublishDate and doesnt have StopPublishDate - which would have been ideal.

#109697
Oct 13, 2014 12:18
Vote:
 

Hmm what if you cast the type in the function?

 query = query.Filter(x => ((PageTYpeBase)x).StopPublish.LessThan(now));

#109698
Oct 13, 2014 12:28
Vote:
 

Thank you very much for your help, this has helped resolved a long running issue. Many thanks :)

#109710
Oct 13, 2014 15:10
Vote:
 

Glad I could help

#109711
Oct 13, 2014 15:19
* 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.