Removing types from Episerver Search results

  • Updated

To remove page types from episerver search(lucene) search results do the below. 

Add the ISearchable interface to your class and add the following properties. 

public bool AllowReIndexChildren { get { return true; } }
public bool IsSearchable { get { return false; } }

 

See the below example from an alloy site. 

namespace EpiSearch.Models.Pages
{
/// 
/// Used primarily for publishing news articles on the website
/// 
[SiteContentType(
GroupName = Global.GroupNames.News,
GUID = "AEECADF2-3E89-4117-ADEB-F8D43565D2F4")]
[SiteImageUrl(Global.StaticGraphicsFolderPath + "page-type-thumbnail-article.png")]
public class ArticlePage : StandardPage, ISearchable
{
public bool AllowReIndexChildren { get { return true; } }
public bool IsSearchable { get { return false; } }
}
 This will make it so that new ArticlePage pages do not get indexed, but what about existing pages of that type? 
 
For that you will need to recreate the index. 

1) Rename \appdata\index to \indexinactive
2) Rebuild the solution
3) Browse to http://hostname/EPiServer/CMS/Admin/IndexContent.aspx or http://hostname/EPiServer/EPiServer.Search.Cms/IndexContent.aspx in later versions.
4) Reindex with delete checked - give it at least five minutes to fully index.
5) Search for items of the page type you wanted excluded.