title: Excluding items selectively from Sitecore's Lucene search index - works when rebuilding with IndexViewer, but not when using Sitecore's built-in tools
body: <p>On a site powered by Sitecore 6.2, I need to give the user the ability to selectively exclude items from search results.</p>
  
  <p>To accomplish this, I have added a checkbox field entitled "Include in Search Results", and I created a custom database crawler to check that field's value:</p>
  
  <p>~\App_Config\Include\Search Indexes\Website.config:</p>
  
  <pre><code>&lt;search&gt;
    &lt;configuration type="Sitecore.Search.SearchConfiguration, Sitecore.Kernel" singleInstance="true"&gt;
      &lt;indexes hint="list:AddIndex"&gt;
        &lt;index id="website" singleInstance="true" type="Sitecore.Search.Index, Sitecore.Kernel"&gt;
          ...
  
          &lt;locations hint="list:AddCrawler"&gt;
            &lt;master type="MyProject.Lib.Search.Indexing.CustomCrawler, MyProject"&gt;
              ...
            &lt;/master&gt;
  
            &lt;!-- Similar entry for web database. --&gt;
          &lt;/locations&gt;
        &lt;/index&gt;
      &lt;/indexes&gt;
    &lt;/configuration&gt;
  &lt;/search&gt;
  </code></pre>
  
  <p>~\Lib\Search\Indexing\CustomCrawler.cs:</p>
  
  <pre><code>using Lucene.Net.Documents;
  using Sitecore.Search.Crawlers;
  using Sitecore.Data.Items;
  
  namespace MyProject.Lib.Search.Indexing
  {
    public class CustomCrawler : DatabaseCrawler
    {
      /// &lt;summary&gt;
      ///   Determines if the item should be included in the index.
      /// &lt;/summary&gt;
      /// &lt;param name="item"&gt;&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      protected override bool IsMatch(Item item)
      {
        if (item["include in search results"] != "1")
        {
          return false;
        }
  
        return base.IsMatch(item);
      }
    }
  }
  </code></pre>
  
  <p>What's interesting is, if I rebuild the index using the Index Viewer application, everything behaves as normal.  Items whose "Include in Search Results" checkbox is not checked will not be included in the search index.</p>
  
  <p>However, when I use the search index rebuilder in the Sitecore Control Panel application or when the IndexingManager auto-updates the search index, all items are included, regardless of the state of their "Include in Search Results" checkbox.</p>
  
  <p>I've also set numerous breakpoints in my custom crawler class, and the application never hits any of them when I rebuild the search index using the built-in indexer.  When I use Index Viewer, it does hit all the breakpoints I've set.</p>
  
  <p>How do I get Sitecore's built-in indexing processes to respect my "Include in Search Results" checkbox? </p>