Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
Join us this Friday for AI in Action at the Virtual Happy Hour! This free virtual event is open to all—enroll now on Academy and don’t miss out.
Have you tried adding .FilterForVisitor() to your search query? This should take care of this.
Thanks for the quick reply.
I tried to add FilterForVisitor() in the query and getting this error;
'ISearch<SearchResult>' does not contain a definition for 'FilterForVisitor' and no extension method 'FilterForVisitor' accepting a first argument of type 'ISearch<SearchResult>' could be found
are there any examples of the usage of this filter?
It will only work for IContent. Here is the documentation: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-Find/10/Integration/EPiServer-75/Filters/
Perhaps you could post your query
I use initialization module to delete expired or deleted pages (inside recycle bin):
[InitializableModule] [ModuleDependency(typeof(InitializationModule))] public class EpiFindInitializationModule : IInitializableModule { private IContentEvents _contentEvents; private IContentEvents ContentEvents { get { return _contentEvents ?? (_contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>()); } } public void Initialize(InitializationEngine context) { ContentEvents.SavedContent += ContentEvents_SavedContent; // exclude deleted (inside recycle bin) or expired pages ContentIndexer.Instance.Conventions .ForInstancesOf<PageData>() .ShouldIndex(x => x.ContentLink.ID != ContentReference.WasteBasket.ID && !x.Ancestors().Contains(ContentReference.WasteBasket.ID.ToString()) && x.StopPublish > DateTime.Now); } private void ContentEvents_SavedContent(object sender, EPiServer.ContentEventArgs e) { var page = e.Content as PageData; // delete expired page if (page != null && page.StopPublish <= DateTime.Now) { SearchClient.Instance.Delete<PageData>(x => x.PageLink.Match(page.PageLink)); } } public void Preload(string[] parameters) { } public void Uninitialize(InitializationEngine context) { ContentEvents.SavedContent -= ContentEvents_SavedContent; } }
And a scheduled job that calls:
SearchClient.Instance.Delete<PageData>(x => x.StopPublish.Before(DateTime.Now))
I'm trying using FilterForVisitor() with no success. I'm still having the expired content in results. Does Find update the index when a user sets expiration on a page in editor mode?
Should I reindex the whole website everytime a single page expires?! That's nonsense... I was hoping that Find has some functionality which removes pages from index if they expire...
It should remove those from index automatically from what I gather with newer versions of Find at least. I know there was a bug with files for expired pages but that was fixed in Episerver Find 12. So I would try running the scheduled job once and see if it works automatically after that.
Hi, I use a Find query on few different page types to retrieves Episerver.Find.SearchResults type data set. The results contain the pages that are 'Expired'. I simply need to remove the 'Expired' pages from the results.
1. Can we avoid indexing 'Expired' pages?
2. How to remove 'Expired' pages from the index? Or
3. How to remove 'Expired' pages from query results?
I tried 'SkipWhile' on the Results, but then it returned no values.
I also tried to add a query filter with 'page.CheckPublishedStatus(PagePublishedStatus.Published)', but it also returned no values.
I believe there must be ab simple easy way to do this. Please help.