How to find out when the Lucene index generation process is complete

I have a Windows.net service that generates Lucene search indexes every night. First, I get all the records from the database and add them to the Lucene index using the IndexWriter AddDocument method, and then I call the Optimize method before returning from the method. Since the extracted records are insufficient, indexing takes about 2-3 minutes. As you already know, Lucene generates intermediate segment files while it generates an index, and compresses the entire index into 3 files when Optimize is called.

Anyway, can I know that this index generation process has been completed by Lucene and the index is searchable? I need to know this because I want to call another method when the process is complete.

+3
source share
2 answers

I do not understand why you need to know when Lucene finishes indexing. You can search while Lucene is indexed. In fact, I think you can search while it optimizes.

I personally don't like the idea of ​​finding a lock file. Can you set a boolean value and switch it after calling the writer.optimize () function?

0
source

Source: https://habr.com/ru/post/1711111/


All Articles