3
votes

I've a .net windows service which generates Lucene search indexes every night. I first get all the records from the database and add it to Lucene index using IndexWriter's AddDocument method and then call Optimize method before returning from the method. Since the records fetched are faily large, indexing takes around 2-3 minutes to complete. As you already know,Lucene generates intermediate segment files while it is generating the index and it compresses the whole index into 3 files when Optimize is called.

Is there anyway I can know that this index generation process is finished by Lucene and index is avaialable for search? I need to know this because I want to call another method when process is completed.

2
You generally don't need to run an optimize every time you generate indexes but if its only taking 2-3 minutes then I guess it isn't hurting anything. Our 82million record lucene/solr index is so large I'm scared to know how long an optimize would take.Hardwareguy

2 Answers

0
votes

I don't understand why you would need to know when Lucene finishes indexing. You can perform searches while Lucene is indexing. In fact, I think you can search while it's optimizing.

I personally do not like the idea of searching for the lock file. Can you not set a boolean and toggle it after you call writer.optimize()?