title: Hibernate search. How to exclude entity from index?
body: <p>I am new at hibernate search and I need to use it with my application database.
  I have a couple of indexed entities classes and I want exclude some entities from index based on their state. I my case I want to exclude objects with template == null I have found <a href="http://docs.jboss.org/hibernate/search/4.1/reference/en-US/html_single/#example-search-mapping-indexinginterceptor-blog" rel="nofollow">this feature</a>  and implemented it but this interceptor not working\invoking</p>
  
  <p>This is what I have</p>
  
  <pre><code>public class WorkDocumentInterceptor implements EntityIndexingInterceptor&lt;WorkDocument&gt; {
  
  @Override
  public IndexingOverride onAdd(WorkDocument workDocument) {
      System.out.println("on ADD workDocument = " + workDocument.getId());
      if (workDocument.getTemplate() == null) {
          System.out.println("SKIP DOCUMENT " + workDocument.getId() + ":" + workDocument.getTitle());
          return IndexingOverride.SKIP;
      }
      return IndexingOverride.APPLY_DEFAULT;
  }
  
  @Override
  public IndexingOverride onUpdate(WorkDocument workDocument) {
      if (workDocument.getTemplate() == null) {
          return IndexingOverride.REMOVE;
      }
      return IndexingOverride.UPDATE;
  }
  
  @Override
  public IndexingOverride onDelete(WorkDocument workDocument) {
      return IndexingOverride.APPLY_DEFAULT;
  }
  
  @Override
  public IndexingOverride onCollectionUpdate(WorkDocument workDocument) {
      return onUpdate(workDocument);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Entity class</p>
  
  <pre><code>@Entity
  @Table(name = "work_document")
  @Indexed(interceptor = WorkDocumentInterceptor.class)
  public class WorkDocument implements Serializable {
  
  
      @Id
      @Basic(optional = false)
      @Column(name = "id")
      private Long id;
  
      Template template;
      ...  
  }
  </code></pre>
  
  <p>When indexing is running I even do not see this output, it seems interceptor not invoking</p>
  
  <pre><code>System.out.println("on ADD workDocument = " + workDocument.getId());
  </code></pre>
  
  <p>To rebuild index I call this</p>
  
  <pre><code>            em.createIndexer(clazz)
                      .purgeAllOnStart(true)
                      .optimizeAfterPurge(true)
                      .optimizeOnFinish(true)
                      .batchSizeToLoadObjects(25)
                      .cacheMode(CacheMode.IGNORE)
                      .threadsToLoadObjects(5)
                      .threadsForIndexWriter(3)
                      .threadsForSubsequentFetching(20)
                      .startAndWait();
  </code></pre>
  
  <p>Why it does not work? Thanks.</p>