Try our conversational search powered by Generative AI!

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
Edited, 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
- Dec 01, 2019 10:40
I would be amazed if everything in this code works.

I think of the Search()-chain as a way of building a search query and would never put calls to the internal APIs there like for example you are doing with contentLoader. This is better solved with adding new properties to your types that support the querying you want do with less query code.

There is a also quite a few redundant calls in there that makes the size of your query bigger to no use - for example calling ExcludeContentFolders when you are already filtering on a specific type.

But just a guess from the thread start is that maybe this is the search page query and by "search bar" you might mean auto suggest on the search form element?

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 11:24
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:28
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
Ash
Vote:
 

I added this line .Filter(x=>x.StopPublish.After(DateTime.Now)), but still getting expired pages.

#207319
Sep 17, 2019 9:03
Vote:
 

@Ash Please contact Application Support and we can check that search request payload looks as expected with that code.

Also include Find index name and give an example on an object you're expecting not to be in the results.

#207421
Edited, Sep 19, 2019 11:51
Ash
Vote:
 

hello everyone,

sorry for the late reply.

but i m getting the same problem and can't resolve this issue till now.

#210582
Nov 28, 2019 14:04
* 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.