There seems to be an issue with this combination. I've set up the application as described here:
http://in.relation.to/Bloggers/HibernateSearch41CR1SoftDeletes. The thing works exactly as advertised and properly removes the documents with unproper status from index. The problem is when I try to reindex the entire database using the mass indexer. It seems that the EntityIndexingInterceptor get's completely ignored as it's not called even once.
I have the most trivial possible implementation of this. Just a boolean field called
active. If true, document should get added to index, otherwise not.
Here's my code.
Interceptor:
Code:
public class IndexWhenActiveInterceptor implements EntityIndexingInterceptor<IndexWhenActive> {
@Override
public IndexingOverride onAdd(IndexWhenActive entity) {
System.out.println("IndexingOverride onAdd");
if (entity.getActive()==null || entity.getActive()) {
return IndexingOverride.APPLY_DEFAULT;
}
return IndexingOverride.SKIP;
}
@Override
public IndexingOverride onUpdate(IndexWhenActive entity) {
System.out.println("IndexingOverride onUpdate: ");
if (entity.getActive()==null || entity.getActive()) {
return IndexingOverride.UPDATE;
}
return IndexingOverride.REMOVE;
}
@Override
public IndexingOverride onDelete(IndexWhenActive entity) {
return IndexingOverride.APPLY_DEFAULT;
}
@Override
public IndexingOverride onCollectionUpdate(IndexWhenActive entity) {
return onUpdate(entity);
}
}
The interface used in interceptor:
Code:
public interface IndexWhenActive {
Boolean getActive();
}
The Entity (partial)
Code:
@Entity
@Table(name="make")
@Indexed(interceptor = IndexWhenActiveInterceptor.class)
public class Make extends BasicEntity implements Serializable, IndexWhenActive {
@Field
private Boolean active = true;
....
}
BasicEntity is a mapped superclass that should not be relevant here.
and finally, the mass indexer code:
Code:
fullTextEntityManager.createIndexer()
.batchSizeToLoadObjects(25)
.threadsToLoadObjects(1)
.threadsForSubsequentFetching(2)
.optimizeOnFinish(true)
.startAndWait();
I'm using this:
Code:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.0.Final</version>
</dependency>
Am I missing something or is there a problem with my implementation.
Please help.
regards.
Jure