Lucene Write Index One of the reasons why a lock file occurs

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.