Hello,
I'm having a similar problem. I also want to update the index via a TimerTask because I get updates of my database from a third party. So I can not benefit of the Hibernate Search transparent index synchronization.
And I can not determine which entities have changed.
So I tried the folowing:
Code:
public void indexInitialization() {
org.hibernate.search.jpa.FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.createFullTextEntityManager(em);
Query query = em.createNamedQuery("findAllUnlockedUserfood");
List<Userfood> userfoods = query.getResultList();
for (Userfood userfood : userfoods) {
// Force the (re)indexing of the userfood
fullTextEntityManager.index(userfood);
}
}
This method is called e.g. every week.
But this method increases the file size of my index even if there are no changes in the database.
Do I have to remove the old Entities from the index before I force the reindex process with the index(Object o) method? Or is there a different approach to do it?
PS: I'm using Hibernate Search 3.0.1 GA
Thanks for your help!