4

I use Hibernate search for full text search in my web application. I have button for index creation in admin panel. I do it by this code:

                fullTextSession.createIndexer()
                .purgeAllOnStart(true)
                .optimizeAfterPurge(true)
                .optimizeOnFinish(true)
                .batchSizeToLoadObjects( 25 )
                .threadsToLoadObjects( 5 )
                .threadsForSubsequentFetching( 20 )
                .startAndWait();

If index was build correctly and then I push this button again old index files still on disk and program creates new index. And so on. Can you help me remove old index files before creating new?

skaffman
  • 398,947
  • 96
  • 818
  • 769
AmarthG
  • 41
  • 1
  • 3

1 Answers1

4

I do a similar thing but only when I shut my app down do I remove the indexes and then I set them up again on startup.

Have you tried calling purgeAll() instead of purgeAllOnStart()? That is what I call on app shutdown and it works. To be safe, after I purge the indexes I actually delete my index directory and all files / folders it contains from disk as well.

brent777
  • 3,369
  • 1
  • 26
  • 35
  • 1
    I've got an [answer](https://forum.hibernate.org/viewtopic.php?f=9&t=1010245) on the HIbernate Search forum – AmarthG Aug 27 '11 at 05:37