how to delete index for a specific page?

Ash
Ash
Vote:
 

how to delete index for a specific page?

#210626
Dec 02, 2019 5:43
Vote:
 

Hi Ash,

Out-of-the-box is not available but you can delete it programmatically.

ContentIndexer.Instance.TryDelete(page, out var result);   

And for future index rebuild, you can introduce a field on the page like "DisableForIndex" and exclude it from the index when rebuilding the index

private bool ShouldIndexPageData(SolutionPageData page)
{
            var wastedContent = ServiceLocator.Current.GetInstance<IContentLoader>().GetDescendents(ContentReference.WasteBasket).ToList();

            //Check if the page is published, not marked as disable indexing, etc 
            var shouldIndex = page.CheckPublishedStatus(PagePublishedStatus.Published)
                              && wastedContent.All(c => c.ID != page.PageLink.ID) //content in wastebasket should not be indexed
                              && !page.DisableIndexing;

            //The page should not be indexed, but in some scenarios it might already be indexed, so try to delete it.
            if (!shouldIndex)
             {
                    ContentIndexer.Instance.TryDelete(page, out var result);         
            }

            return shouldIndex;
}

More info available here

https://world.episerver.com/forum/developer-forum/-Episerver-75-CMS/Thread-Container/2017/11/pages-moved-to-trash--not-deleted-from-the-searchindex/

#210627
Dec 02, 2019 6:36
Ash
Vote:
 

Hello Ravindra,

Thanks for the reply, but i want to delete index for expired pages so where i have to place this "ContentIndexer.Instance.TryDelete(page, out var result);" in code.

#210628
Dec 02, 2019 6:55
Ash
Vote:
 

Hello Ravindra.

Is this method also works for the deleted pages?

#210630
Dec 02, 2019 7:18
Ravindra S. Rathore - Dec 02, 2019 8:17
Please follow the article I mentioned
https://world.episerver.com/blogs/Henrik-Fransas/Dates/2015/5/adding-episerver-find-to-alloy---part-2/
Vote:
 

If you want to do this manually, I think the easiest is to install the nuget package EpiCode.InspectInIndex as described here: https://www.gulla.net/inspect-your-episerver-find-index/

#210641
Dec 02, 2019 12:08
Ash
Vote:
 

Hello Tomas ,

Thanks for the reply.

I had resolved my issue.

#210642
Dec 02, 2019 12:12
- Dec 02, 2019 12:15
Excellent!
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.