Sometimes there is need to re-build a lucene-index from scratch. As I do not want the index to be incomplete for several hours while building, I am using a separate compass instance to build the new index and replace it in the filesystem afterwards.
Before doing so, all compass instances are stopped using SearchEngineIndexManager#stop()
, afterwards they are restarted using SearchEngineIndexManager#start()
However, every now and then, the index seems to get corrupted during this operations.
Is it not safe to replace an index in the filesystem when the SearchEngineIndexManger is stopped? Are there any other necessary precautions to consider if I need to operate on a lucene index in the file system?
I managed to fix the problem by adding 5 seconds of
sleep
after stopping and before re-starting theIndexManager
. Might be an ugly solution, but works for me.To be sure, I have also added a call to SearchEngineIndexManager#clearCache() after re-starting.