如何解锁lucene中的索引目录

时间:2012-11-21 04:37:35

标签: java lucene

如果在使用java中的lucene api 3.0时,如何解锁SimpleFsFactory中的索引目录?unlock()方法无效。我是使用lucene的新手? / p>

1 个答案:

答案 0 :(得分:5)

我这样做,对我有用:

    Directory directory = FSDirectory.open(folder);
    if (directory.fileExists(IndexWriter.WRITE_LOCK_NAME)) {
        directory.clearLock(IndexWriter.WRITE_LOCK_NAME);
        log.warn("Existing write.lock at [" + folder.getAbsolutePath() + "] has been found and removed. This is a likely result of non-gracefully terminated server. Check for index discrepancies!");
    }
    directory.close();