`

lucene:java.io.IOException: Cannot overwrite: .fdt

阅读更多

原因:

1、手工删除索引文件导致。

2、磁盘错误导致。

 

解决办法:

方法一:重启lucene服务。

 

 

出错样例:

 

HI There

I keep getting the following error when simultaneously reindexing my 
documents and searching through the index.

java.io.IOException: Cannot overwrite: C:\index9121\_2.cfs
    at 
org.apache.lucene.store.FSDirectory.createOutput(FSDirectory.java:433)
    at 
org.apache.lucene.index.CompoundFileWriter.close(CompoundFileWriter.java:150)
    at 
org.apache.lucene.index.DocumentsWriter.createCompoundFile(DocumentsWriter.java:569)
    at org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:2565)
    at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:2397)
    at 
org.apache.lucene.index.IndexWriter.closeInternal(IndexWriter.java:1204)
    at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:1178)
    at org.apache.lucene.index.IndexWriter.close(IndexWriter.java:1153)

Consequently, often documents are missing from the index. Does one have 
to perform any synchronized across IndexWriter and IndexReader? I 
assumed that Lucene took care of this. I sincerely appreciate any 
guidance on offer!'

Many thanks
Jamie

PS: Here is the Lucene indexing debug information.

IFD [http-8090-2]: setInfoStream 
deletionPolicy=org.apache.lucene.index.KeepOnlyLastCommitDeletionPolicy@1ae3b4d
IW 27 [http-8090-2]: setInfoStream: 
dir=org.apache.lucene.store.FSDirectory@C:\index9121 autoCommit=false 
mergePolicy=org.apache.lucene.index.LogByteSizeMergePolicy@1b7682d 
mergeScheduler=org.apache.lucene.index.ConcurrentMergeScheduler@1873a6 
ramBufferSizeMB=16.0 maxBuffereDocs=-1 maxBuffereDeleteTerms=-1 
maxFieldLength=50000 index=_3:c113 _4:c70 _5:c44 _6:c68
IW 27 [Timer-0]: now flush at close
IW 27 [Timer-0]:   flush: segment=_7 docStoreSegment=_7 docStoreOffset=0 
flushDocs=true flushDeletes=false flushDocStores=true numDocs=27 
numBufDelTerms=0
IW 27 [Timer-0]:   index before flush _3:c113 _4:c70 _5:c44 _6:c68

flush postings as segment _7 numDocs=27

closeDocStore: 2 files to flush to segment _7 numDocs=27
  oldRAMSize=212992 newFlushedSize=32784 docs/MB=863.578 new/old=15.392%
IFD [Timer-0]: now checkpoint "segments_5" [5 segments ; isCommit = false]
IFD [Timer-0]: delete pending file _9s.cfs
IFD [Timer-0]: delete "_9s.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9s.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9s.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9y.cfs
IFD [Timer-0]: delete "_9y.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9y.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9y.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9x.cfs
IFD [Timer-0]: delete "_9x.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9x.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9x.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9v.cfs
IFD [Timer-0]: delete "_9v.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9v.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9v.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9z.cfs
IFD [Timer-0]: delete "_9z.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9z.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9z.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9t.cfs
IFD [Timer-0]: delete "_9t.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9t.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9t.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9x.cfx
IFD [Timer-0]: delete "_9x.cfx"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9x.cfx": 
java.io.IOException: Cannot delete C:\index9121\_9x.cfx; Will re-try later.
IFD [Timer-0]: delete pending file _9u.cfs
IFD [Timer-0]: delete "_9u.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9u.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9u.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9w.cfs
IFD [Timer-0]: delete "_9w.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9w.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9w.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9t.cfx
IFD [Timer-0]: delete "_9t.cfx"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9t.cfx": 
java.io.IOException: Cannot delete C:\index9121\_9t.cfx; Will re-try later.
IFD [Timer-0]: now checkpoint "segments_5" [5 segments ; isCommit = false]
IFD [Timer-0]: delete pending file _9s.cfs
IFD [Timer-0]: delete "_9s.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9s.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9s.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9y.cfs
IFD [Timer-0]: delete "_9y.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9y.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9y.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9x.cfs
IFD [Timer-0]: delete "_9x.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9x.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9x.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9v.cfs
IFD [Timer-0]: delete "_9v.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9v.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9v.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9z.cfs
IFD [Timer-0]: delete "_9z.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9z.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9z.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9t.cfs
IFD [Timer-0]: delete "_9t.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9t.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9t.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9x.cfx
IFD [Timer-0]: delete "_9x.cfx"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9x.cfx": 
java.io.IOException: Cannot delete C:\index9121\_9x.cfx; Will re-try later.
IFD [Timer-0]: delete pending file _9u.cfs
IFD [Timer-0]: delete "_9u.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9u.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9u.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9w.cfs
IFD [Timer-0]: delete "_9w.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9w.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9w.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9t.cfx
IFD [Timer-0]: delete "_9t.cfx"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9t.cfx": 
java.io.IOException: Cannot delete C:\index9121\_9t.cfx; Will re-try later.
IFD [Timer-0]: delete "_7.fnm"
IFD [Timer-0]: delete "_7.frq"
IFD [Timer-0]: delete "_7.prx"
IFD [Timer-0]: delete "_7.tis"
IFD [Timer-0]: delete "_7.tii"
IFD [Timer-0]: delete "_7.nrm"
IFD [Timer-0]: delete "_7.fdx"
IFD [Timer-0]: delete "_7.fdt"
IW 27 [Timer-0]: LMP: findMerges: 5 segments
IW 27 [Timer-0]: LMP:   level -1.0 to 5.250432: 5 segments
IW 27 [Timer-0]: CMS: now merge
IW 27 [Timer-0]: CMS:   index: _3:c113 _4:c70 _5:c44 _6:c68 _7:c27
IW 27 [Timer-0]: CMS:   no more merges pending; now return
IW 27 [Timer-0]: close: wrote segments file "segments_6"
IFD [Timer-0]: now checkpoint "segments_6" [5 segments ; isCommit = true]
IFD [Timer-0]: delete pending file _9s.cfs
IFD [Timer-0]: delete "_9s.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9s.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9s.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9y.cfs
IFD [Timer-0]: delete "_9y.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9y.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9y.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9x.cfs
IFD [Timer-0]: delete "_9x.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9x.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9x.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9v.cfs
IFD [Timer-0]: delete "_9v.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9v.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9v.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9z.cfs
IFD [Timer-0]: delete "_9z.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9z.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9z.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9t.cfs
IFD [Timer-0]: delete "_9t.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9t.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9t.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9x.cfx
IFD [Timer-0]: delete "_9x.cfx"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9x.cfx": 
java.io.IOException: Cannot delete C:\index9121\_9x.cfx; Will re-try later.
IFD [Timer-0]: delete pending file _9u.cfs
IFD [Timer-0]: delete "_9u.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9u.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9u.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9w.cfs
IFD [Timer-0]: delete "_9w.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9w.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9w.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9t.cfx
IFD [Timer-0]: delete "_9t.cfx"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9t.cfx": 
java.io.IOException: Cannot delete C:\index9121\_9t.cfx; Will re-try later.
IFD [Timer-0]: deleteCommits: now remove commit "segments_5"
IFD [Timer-0]: delete "segments_5"
IW 27 [Timer-0]: at close: _3:c113 _4:c70 _5:c44 _6:c68 _7:c27
IFD [Timer-0]: delete pending file _9s.cfs
IFD [Timer-0]: delete "_9s.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9s.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9s.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9y.cfs
IFD [Timer-0]: delete "_9y.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9y.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9y.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9x.cfs
IFD [Timer-0]: delete "_9x.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9x.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9x.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9v.cfs
IFD [Timer-0]: delete "_9v.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9v.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9v.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9z.cfs
IFD [Timer-0]: delete "_9z.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9z.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9z.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9t.cfs
IFD [Timer-0]: delete "_9t.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9t.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9t.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9x.cfx
IFD [Timer-0]: delete "_9x.cfx"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9x.cfx": 
java.io.IOException: Cannot delete C:\index9121\_9x.cfx; Will re-try later.
IFD [Timer-0]: delete pending file _9u.cfs
IFD [Timer-0]: delete "_9u.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9u.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9u.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9w.cfs
IFD [Timer-0]: delete "_9w.cfs"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9w.cfs": 
java.io.IOException: Cannot delete C:\index9121\_9w.cfs; Will re-try later.
IFD [Timer-0]: delete pending file _9t.cfx
IFD [Timer-0]: delete "_9t.cfx"
IFD [Timer-0]: IndexFileDeleter: unable to remove file "_9t.cfx": 
java.io.IOException: Cannot delete C:\index9121\_9t.cfx; Will re-try later.







OK indeed from your code you are manually removing files from the
index (the "deleteIndex" method).  You shouldn't do that.

I think what's happening is deleteIndex is called when an IndexReader
has the index open (do you see those "failed to delete file in
existing index" log messages?), then you open a writer on that
directory.  That would exactly explain your exception.

The fix is simple: never remove files from the index yourself.  Let
IndexWriter do it, by opening with create=true.  It will take care of
removing the old files, retrying over time, etc.

And, most importantly, this allows you to create a new index in a
directory even while an IndexReader is still using it.  The reader
will be fine, and then when it reopens it will switch to the new
index.

Lucene 2.3 can read 2.2 indices but not vice versa, so you can't
downgrade unless you completely remove your index.

Mike

Jamie <jamie@stimulussoft.com> wrote:

分享到:
评论

相关推荐

    Lucene使用

    Exception in thread "main" java.lang.AbstractMethodError: org.apache.lucene.analysis.TokenStream.incrementToken()Z 换用svn里源码版正常 http://paoding.googlecode.com/svn/trunk/paoding-analysis/

    java.lang.NoSuchFieldError Companion

    java.lang.NoSuchFieldError: Companion 问题的解决方案

    lucene-core-7.7.0-API文档-中文版.zip

    标签:apache、lucene、core、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明精准翻译,请放心...

    socket.io-client-2.2.0.zip

    - **概述**:Hibernate Search是Hibernate ORM的一个模块,允许开发者在Java应用中执行全文本搜索,支持Lucene搜索引擎。 - **集成**:它无缝集成到现有的Hibernate实体模型,使得数据库中的数据可以被索引和搜索...

    与lucene3.0兼容的庖丁jar包

    Exception in thread "main" java.lang.AbstractMethodError: org.apache.lucene.analysis.TokenStream.incrementToken()Z at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField....

    指南-Lucene:ES篇.md

    指南-Lucene:ES篇.md

    IKAnalyzer中文分词支持lucene6.5.0版本

    由于林良益先生在2012之后未对IKAnalyzer进行更新,后续lucene分词接口发生变化,导致不可使用,所以此jar包支持lucene6.0以上版本

    java.lang.NoSuchFieldError: STRING

    解决 java.lang.NoSuchFieldError: STRING at org.jbpm.identity.hibernate.PermissionUserType. 不用jbpm的jbpm-identity.jar 用这个就好

    Lucene学习源码.rar

    4. `org.apache.lucene.search.Query` 和 `org.apache.lucene.queryparser.classic.QueryParser`:理解查询的构建和解析过程。 5. `org.apache.lucene.search.Searcher`:研究搜索过程,特别是如何计算相关性和返回...

    lucene-analysis.jar

    《深入理解Lucene分析器库:lucene-analysis.jar解析》 在信息检索和搜索引擎领域,Apache Lucene是一个广泛使用的开源全文检索库。它的核心功能包括文档的索引、搜索以及相关的高级特性。其中,"lucene-analysis....

    apache-lucene-analyzers.jar

    Apache Lucene是一个高性能、全文本搜索库,广泛用于构建搜索引擎应用程序。这个名为"apache-lucene-analyzers.jar"的文件是Lucene项目的一部分,主要包含了各种分析器(analyzers)的实现,它们在处理文本数据时起...

    [开发自己的搜索引擎:Lucene.Heritrix(第2版)].邱哲.扫描版.pdf

    [开发自己的搜索引擎:Lucene.Heritrix(第2版)].邱哲.扫描版.pdf

    Lucene:基于Java的全文检索引擎简介

    Lucene是一个基于Java的全文索引工具包。 1. 基于Java的全文索引引擎Lucene简介:关于作者和Lucene的历史 2. 全文检索的实现:Luene全文索引和数据库索引的比较 3. 中文切分词机制简介:基于词库和自动切分词算法的...

    最新版linux lucene-8.10.0.tgz

    Linux Lucene 8.10.0是Apache Lucene项目的一个关键版本,它是一个高性能、全功能的文本搜索库,广泛应用于Java开发中。Lucene提供了丰富的搜索功能,包括全文检索、高级分析器、索引优化等,为开发者构建复杂的搜索...

    lucene:Node.js库进行转换

    lucene 解析,修改和字符串化Lucene查询。 | | 安装 npm install --save lucene -or- yarn add lucene 用法 const lucene = require ( 'lucene' ) ; const ast = lucene . parse ( 'name:frank OR job:engineer' )...

    Lucene.Net.Analysis.Cn.dll

    在C#开发中,搜索引擎的构建是不可或缺的一部分,而Lucene.Net作为一个强大的全文搜索引擎库,为开发者提供了丰富的功能。本文将重点探讨Lucene.Net.Analysis.Cn.dll和Lucene.Net.dll这两个关键组件在C#环境下的作用...

    lucene-spatial-6.6.0-API文档-中英对照版.zip

    标签:apache、lucene、spatial、jar包、java、API文档、中英对照版; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构保持不变,注释和说明...

    Lucene建立索引及查询包含“java”关键字 示例代码

    import java.io.IOException; import java.nio.file.Paths; public class SearchingExample { public static void main(String[] args) throws Exception { Directory directory = FSDirectory.open(Paths.get(...

    lucene-codecs-4.4.0.zip

    《深入理解Lucene 4.4.0代码库与Java核心技术》 在IT领域,Lucene是一个非常重要的开源全文搜索引擎库,它为开发者提供了强大的文本分析、索引和搜索功能。这里我们关注的是Lucene的4.4.0版本,通过解压"lucene-...

    lucene for java 简单demo

    import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.StringField; import ...

Global site tag (gtag.js) - Google Analytics