I am writing a wrapper around Zend's lucene implementation and wanted to add a function rebuildIndex()
which reads all relevant fields from the database and re-creates the index file in a temporary folder. When the operation is finished, I want to replace the original folder with the new one. How can I lock the original lucene folder while replacing its contents? I haven't found anything in Zend's API docs, but I had read somewhere that locking works with files in lucene. Which folders/files do I need?
Lucene use locking internally to maintain index consistency, so you can not use it in your code. I'd suggest using the following strategy: