lucene创建索引中的构造函数IndexWriter(Stringpath, Analyzer a, boolean create, IndexWriter.MaxFieldLength mfl),这里的boolean create参数的意思并非是否创建索引,而是覆盖还是追加的意思。原文见官方文档:create - trueto create the index or overwrite the existing one; false to appendto 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 inorg.apache.lucene.store.FSDirectory@D:/lucenedir/index:files:
atorg.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:604)
atorg.apache.lucene.index.SegmentInfos.read(SegmentInfos.java:272)
atorg.apache.lucene.index.IndexWriter.init(IndexWriter.java:1072)
atorg.apache.lucene.index.IndexWriter.(IndexWriter.java:550)
?
原文:http://blog.csdn.net/honglei_zh/article/details/8140188