title: Sitecore 8 XP ContentSearch: Exclude path from Indexing
body: <p>I'm having trouble with Sitecore Indexing of the general indexes "sitecore_master_index", "sitecore_web_index", which take forever because the crawler/indexer checks all items in the database.</p>
  
  <p>I imported thousands of products with a whole lot of specifications and literally have hundreds of thousands of items in the product repository.</p>
  
  <p>If I could exclude the path from indexing it wouldn't have to check a million items for template exclusion.</p>
  
  <p>FOLLOWUP</p>
  
  <p>I implemented a custom-crawler that excludes a list of paths from being indexed:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;index id="sitecore_web_index" type="Sitecore.ContentSearch.SolrProvider.SwitchOnRebuildSolrSearchIndex, Sitecore.ContentSearch.SolrProvider"&gt;
    &lt;param desc="name"&gt;$(id)&lt;/param&gt;
    &lt;param desc="core"&gt;sitecore_web_index&lt;/param&gt;
    &lt;param desc="rebuildcore"&gt;sitecore_web_index_sec&lt;/param&gt;
    &lt;param desc="propertyStore" ref="contentSearch/indexConfigurations/databasePropertyStore" param1="$(id)" /&gt;
    &lt;configuration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration" /&gt;
    &lt;strategies hint="list:AddStrategy"&gt;
      &lt;strategy ref="contentSearch/indexConfigurations/indexUpdateStrategies/onPublishEndAsync" /&gt;
    &lt;/strategies&gt;
    &lt;locations hint="list:AddCrawler"&gt;
      &lt;crawler type="Sitecore.ContentSearch.Utilities.Crawler.ExcludePathsItemCrawler, Sitecore.ContentSearch.Utilities"&gt;
        &lt;Database&gt;web&lt;/Database&gt;
        &lt;Root&gt;/sitecore&lt;/Root&gt;
        &lt;ExcludeItemsList hint="list"&gt;
          &lt;ProductRepository&gt;/sitecore/content/Product Repository&lt;/ProductRepository&gt;
        &lt;/ExcludeItemsList&gt;
      &lt;/crawler&gt;
    &lt;/locations&gt;
  &lt;/index&gt;
  </code></pre>
  
  <p>In addition I activated SwitchOnSolrRebuildIndex as it's awesome ootb functionality, cheers SC.</p>
  
  <pre class="lang-cs prettyprint-override"><code>using System.Collections.Generic;
  using System.Linq;
  using Sitecore.ContentSearch;
  using Sitecore.Diagnostics;
  
  namespace Sitecore.ContentSearch.Utilities.Crawler
  {
    public class ExcludePathsItemCrawler : SitecoreItemCrawler
    {
      private readonly List&lt;string&gt; excludeItemsList = new List&lt;string&gt;();
      public List&lt;string&gt; ExcludeItemsList
      {
        get
        {
          return excludeItemsList;
        }
      }
  
      protected override bool IsExcludedFromIndex(SitecoreIndexableItem indexable, bool checkLocation = false)
      {
        Assert.ArgumentNotNull(indexable, "item");
        if (ExcludeItemsList.Any(path =&gt; indexable.AbsolutePath.StartsWith(path)))
        {
          return true;
        }
        return base.IsExcludedFromIndex(indexable, checkLocation);
      }
    }
  }
  </code></pre>