Expired pages are still appearing in the search bar at the front end

ash
ash
Vote:
 

Expired pages are still appearing in the search bar at the front end

#207129
Sep 11, 2019 7:10
Vote:
 

Hi Ash,

Have you tried adding .FilterForVisitor() to your search query?

This should take care of this.

#207131
Sep 11, 2019 7:34
ash
Vote:
 

No, it is not working

#207136
Sep 11, 2019 9:25
Vote:
 

Can you please post your code snippet here?

I don't think this is required step but have you rebuilt the index after page expires.

#207137
Sep 11, 2019 9:35
ash
Vote:
 
 return _searchClient.Search<ContentPageBase>(Language.English
                
                .For(searchTerm) 
                .WithAndAsDefaultOperator() 
                .UsingAutoBoost(TimeSpan.FromDays(14))
                .UsingSynonyms() 
                .FilterByExactTypes(new[] { typeof(HeritagePropertyLandingPage) }) 
                .Filter(x => !x.MatchType(typeof(EventPage)) | (x as EventPage).End_Date.After(
                                 new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59))) 
                .CurrentlyPublished() 
                .ExcludeDeleted() 
                .ExcludeContentFolders() 
                .PublishedInCurrentLanguage() 
                .FilterForVisitor()                
 .BoostMatching(x => x.PageTitle.MatchCaseInsensitive(searchTerm), 80) 
                .ApplyBestBets() 
                .Skip((page - 1) * itemsPerPage)
                .Take(itemsPerPage)
                .Select(x => new SearchResultViewModel { Title = x.PageTitle, Description = x.PageDescription, TargetUrl = x.ContentLink, ItemType = "Page" })
                .IncludeType<SearchResultViewModel, NewsStoryPage>(x => new SearchResultViewModel { Title = x.PageTitle, Description = x.PageDescription, TargetUrl = x.ContentLink, ItemType = "News" })
                .IncludeType<SearchResultViewModel, EventPage>(x => new SearchResultViewModel { Title = x.PageTitle, Description = x.PageDescription, TargetUrl = x.ContentLink, ItemType = "Event" })
                .IncludeType<SearchResultViewModel, HeritagePropertyLandingPage>(x => new SearchResultViewModel { Title = x.PageTitle, Description = x.PageDescription, TargetUrl = x.ContentLink, ItemType = "Property", ImageResizerSetting = ImageResizerSetting, Image = (x.PageImage != ContentReference.EmptyReference && x.PageImage != null) ? _contentLoader.Get<ImageFile>(x.PageImage) : null })
                .Track() 
                .GetResult();
#207139
Sep 11, 2019 10:40
Vote:
 

Thanks for providing the code here.

I think the code looks good . Have you tried with rebuild index?

#207142
Sep 11, 2019 11:18
ash
Vote:
 

 Is it necessary to rebuild index everyime after page expires? That's nonsense... I was hoping that Find has some functionality which removes pages from index if they expire... 

#207144
Edited, Sep 11, 2019 12:05
Vote:
 

I think no but I read somewhere that it is a bug in some earlier version of Episerver find.

#207145
Sep 11, 2019 12:06
ash
Vote:
 

so what should i do now??

#207146
Edited, Sep 11, 2019 12:09
Vote:
 

Go to Episerver CMS admin panel and run the "EPiServer Find Content Indexing Job".

#207150
Sep 11, 2019 12:16
ash
Vote:
 

Should I reindex the whole website everytime a single page expires?

#207151
Sep 11, 2019 12:20
Vote:
 

No, but if this resolves your issue then you can write some custom schedule jobs, etc.. to handle your scenario so please try once.

Are you using the Episerver Find 12 or lower?

#207152
Sep 11, 2019 12:25
ash
Vote:
 

i m using episerver find 13.2.2 .

I have to rebuild indexing after the expiration of the single page even after doing code

#207153
Edited, Sep 11, 2019 12:30
Vote:
 

could you add a .Filter() to check if the expiry date has passed and filter out the expired content? 

#207155
Sep 11, 2019 13:26