lucene:no segments* file found in org.apache.lucene.store.FSDirectory@

来源:互联网 发布:淘宝优惠券设置 编辑:程序博客网 时间:2024/04/30 13:18
    lucene创建索引中的构造函数IndexWriter(String path, Analyzer a, boolean create, IndexWriter.MaxFieldLength mfl) ,这里的boolean create参数的意思并非是否创建索引,而是覆盖还是追加的意思。原文见官方文档:create - true to create the index or overwrite the existing one; false to append to the existing index

create - true to create the index or overwrite the existing one; false to append to the existing index
true:创建新的索引或者覆盖现有索引
false:追加索引到现有索引。

所以。当该参数为false,而所以目录下由不存在索引的时候,便会产生该异常。

java.io.FileNotFoundException: no segments* file found in org.apache.lucene.store.FSDirectory@D:/lucenedir/index: files:
at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:604)
at org.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:272)
at org.apache.lucene.index.IndexWriter.init(IndexWriter.java:1072)
at org.apache.lucene.index.IndexWriter.(IndexWriter.java:550)
原创粉丝点击