The Lucene index file on the company's website is automatically generated every day. Of course, this is also because of the need. This morning, we found a problem: an index error occurred during the generation process, the direct consequence is that the search content is almost empty!
So how can we avoid a similar problem? I used to set the index file location and the index file location during search to two directories.
For example, when an index is generated: The index is generated to the index_bak directory.
Use the index file under the index directory during search
ProgramThe running process is as follows:
1. Determine whether index_bak exists. Otherwise, create
2. generate an index file in the index_bak directory. If any error occurs, return false and record the log.
3. If there is no error, delete the original index under the index directory.
4. Change the index_bak name to index.
This is the above method. If you have a better solution, please let us know.