您的位置:首页 > 运维架构 > Apache

no segments* file found in org.apache.lucene.store.SimpleFSDirectory

2016-07-03 23:49 896 查看
建立好文件索引后,再执行搜索个过程中出现了这个异常:

rg.apache.lucene.index.IndexNotFoundException: no segments* file found in org.apache.lucene.store.SimpleFSDirectory@D:\lucene\index01 lockFactory=org.apache.lucene.store.NativeFSLockFactory@26e431: files: [write.lock, _0.fdt, _0.fdx]  

    at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:712)  

    at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:75)  

    at org.apache.lucene.index.IndexReader.open(IndexReader.java:462)  

    at org.apache.lucene.index.IndexReader.open(IndexReader.java:308)  

    at com.lyl.test.HelloLucene.sercher(HelloLucene.java:73)  

    at com.lyl.test.TestLucene.search1(TestLucene.java:19)  

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)  

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)  

    at java.lang.reflect.Method.invoke(Method.java:597)  

单元测试过程中,创建索引读取器IndexReader的时候,抛出异常,并发现索引文件都为0kb,最终确认是索引IndexWriter写入器没有将缓存中的信息输入文件内,

 

解决方法是:写入器添加好文件索引后,关闭写入器,就ok了!

if(writer
!=null) writer.close();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Lucene 异常