How to remove old Hibernate Search index
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?
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.
精彩评论