Lucene Normal directory file has three files.
Segments.gen segments_a08, there is something like _uw.cfs name. Of course, it's not all the same, but it's definitely the three. If a lot of files appear. Don't worry, look at the following.
If there are many files in the index directory of Lucene, there must be a problem. Several aspects. First Lucene writes a file in the directory, such as a write.lock, to lock the directory, to avoid other indexes to manipulate the path. Otherwise, that would be messy. After locking, start writing index, when writing index Lucene built several or dozens of temporary fragment files, all seem to be short and chaotic characters. cfs files. When the index is established, indexwriter.optimize () is not executed, and he will not merge the messy files. Therefore, after the completion of the index, it is important to implement the above optimization method, keep the directory 3 files can be kept. That is, many temporary files are merged into a single file. Do not remove the effect. But when there is a lot of data, consider the strategy separately.
Lucene uses the index directory to build the Write.lock file to identify the lock when writing to the index. The lock file is deleted only after the close () method is executed. As long as this file exists, other programs that write the index will get an error:
Caught a class org.apache.lucene.store.LockObtainFailedException
With Message:lock obtain timed out: [Email protected]:javasourcelucenetestindexwrite.lock
Therefore, it is important to note that the indexwrite must be closed. including exceptions, close with finally. This will cause the next write index to fail. After modifying the program, delete the Write.lock file directly.
Reprint note This article address: http://www.ablanxue.com/shtml/201411/25889_1.shtml
Lucene Write Index One of the reasons why a lock file occurs