I am trying to index an embedded collection (Set) having one-to-many association using @IndexedEmbedded.The problem is that we are only soft deleting the records in our application and I want to apply hibernate filter on the indexed collection so as to exclude the logically deleted records while indexing.
@Index
Class A {
@IndexedEmbedded
@OneToMany(targetEntity = B.class, fetch = FetchType.EAGER)
@Filter(name = "deletedRecordsFilter")
Set<B> setOfBs;
}
For Indexing :
FullTextSession fts = getFullTextSession();
fts.createIndexer(entityClass)
.purgeAllOnStart(true)
.optimizeAfterPurge(true)
.optimizeOnFinish(true)
.batchSizeToLoadObjects(30)
.threadsForSubsequentFetching(8)
.threadsToLoadObjects(4)
.threadsForIndexWriter(3)
.startAndWait();
I have enabled the filter using session.enableFilter("deletedFilterRecords"). The data is indexed but the filter is not working properly. The embedded collections still contain the deleted records.
Is that hibernate filters do not work while indexing through hibernate search or am I missing something? If filters do not work while indexing, then is there any way so as not to index the logically deleted records?