创建第一个lucene索引后,搜索出错:

org.apache.lucene.index.IndexNotFoundException: no segments* file found in org.apache.lucene.store.MMapDirectory@H:\lucene lockFactory=org.apache.lucene.store.NativeFSLockFactory@487c9b46: 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 lucene.Searcher.search(Searcher.java:26)

at lucene.Searcher.main(Searcher.java:49)


原因:

indexer创建完索引后没有关闭(提交)导致索引没有完整创建,导致搜索报错

注意如下说明:(index.close())

public static void main(String[] args) {long start = System.currentTimeMillis();Indexer indexer = null;int numIndexed = 0;try {indexer = new Indexer(indexDir);numIndexed = indexer.index(dataDir, new TextFilesFilter());} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}finally{try {//IndexerWriter写索引操作关闭,提交写索引(如没关闭会造成索引无法完整创建,查询时出错)indexer.close();} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}long end = System.currentTimeMillis();System.out.println("\n Indexing " + numIndexed + " files took "+ (end - start) + "milliseconds");}

lucene 索引出错 no segments* file found in org.apache.lucene.store.MMapDirectory相关推荐

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

    建立好文件索引后,再执行搜索个过程中出现了这个异常: rg.apache.lucene.index.IndexNotFoundException: no segments* file found in ...

  2. lucene索引的删除和更新

    Lucene索引的删除和更新 删除和更新和新增一样,也是通过IndexWriter 对象来操作的,IndexWrite对象的deleteDocuments ()方法用于实现索引的删除,updateDo ...

  3. 数据检索---基于Lucene索引

    有了大量的数据之后,想要找到特定的数据,模糊查询,也是一个巨大的挑战.这里有来一起回顾下Lucene索引.(以下很多来自百度百科,算作是科普吧) 说起Lucene,它是apache软件基金会jakar ...

  4. A SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'Lucene40' does not exist.

    简单的建立索引和查询索引并不难,关键在于他的二次开发,让他适合你自己的需求 既然要二次开发就必须查看源码 首先看看索引过程中的核心类吧: IndexWriter 这个是核心组件, 建立和打开索引,以及 ...

  5. apache lucene_全文搜索Apache Lucene简介

    apache lucene 在本教程中,我想谈谈Apache Lucene . Lucene是一个开源项目,提供基于Java的索引和搜索技术. 使用其API,很容易实现全文搜索 . 我将处理Lucen ...

  6. solr和lucene_使用Apache Lucene和Solr 4进行下一代搜索和分析

    solr和lucene 六年前,我开始为developerWorks撰写有关Solr和Lucene的文章(请参阅参考资料 ). 多年来,Lucene和Solr确立了自己的坚如磐石的技术(Lucene作 ...

  7. 关于org.apache.lucene.queryParser.ParseException: Encountered 解决方法

    现象: org.apache.lucene.queryParser.ParseException: Encountered "<EOF>" at line 1, col ...

  8. 如何在Hibernate Search 5.5.2 / Apache Lucene 5.4.x中处理停用词?

    停用词,例如[" a"," an"," and"," are"," as"," at&qu ...

  9. at org.apache.lucene.analysis.Analyzer.tokenStream(Analyzer.java:162)错误的解决办法主要是针对IK分词的结果运行错误解决

    主要错误信息 Exception in thread "main" java.lang.AbstractMethodError: org.apache.lucene.analysi ...

最新文章

  1. mysql主从复制,半同步,主主复制架构的实现
  2. 测试在强电磁场下基于HALL的电流传感器 ACS712-5A是否会有到影响?
  3. @select 怎么写存储过程_MySQL4:存储过程和函数
  4. 面试官:数据量大的情况下分页查询很慢,有什么优化方案?
  5. Octave: 'rgb2gray' undefined error
  6. 中班音乐计算机反思,中班音乐教学反思
  7. 解决金蝶未检测到K/3许可文件,并且该账套已超过演示版期限问题
  8. Mongo数据库慢查询功能
  9. Javascript第六章闭包closure规则第三课
  10. HAOI2018 简要题解
  11. 虚拟机安装系统 小计
  12. matlab 符号运算 简化,Matlab 符号运算的因式分解、展开与合并、简化
  13. java毕业设计和毕业论文怎么写,答辩流程是怎样的?
  14. win10安装CA证书服务器,分享一下win10系统安装数字证书的方法
  15. AlertManager配置参数解析
  16. 2018携程校招笔试第二道编程题
  17. Flink 灵魂两百问,这谁顶得住?
  18. linu系统中dhcp的搭建
  19. 瀑布模型,迭代模型,敏捷开发
  20. 一个强悍而优美的Android视频播放器

热门文章

  1. 计算机应用基础怎么教作业,北京语言大学网络教育2017春计算机应用基础作业(1)及答案...
  2. 米家zigbee传感器抓包_如果有一代,米家人体传感器2值得你去更换吗?
  3. Swift--基本数据类型(二)
  4. 巧用这19条MySQL优化,效率至少提高3倍
  5. 转载,关于缓存穿透、缓存并发、缓存雪崩那些事
  6. 方法重载,new,override
  7. oracle查看和替换含不可见字符(空白)
  8. 高性能 TCP UDP 通信框架 HP-Socket v3.2.3
  9. Jni Helloworld
  10. sicily 1021. Couples 栈