`
houzhaowei
  • 浏览: 492606 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

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

阅读更多

遇到以上异常,原因:

       

 writer = new IndexWriter(indexPath, getAnalyzer(),
                 true, IndexWriter.MaxFieldLength.UNLIMITED);

 

其中"true"为在indexPath 目录下不新建索引而使用原来的索引,在第一次建立索引时会遇到"no segments* file found in org.apache.lucene.store.FSDirectory" 的异常。因为还没有在该目录建立任何索引文件。

解决方案:

目前想到这个解决方案,还没想到更好的:

File file = new File(indexPath);
				//如果目录下没有文件,则新建索引文件
				if(file.isDirectory() && file.listFiles().length == 0){
					writer = new IndexWriter(indexPath, getAnalyzer(),
							true, IndexWriter.MaxFieldLength.UNLIMITED);
				} else {
					//如果已有索引文件则用原有的索引文件
					writer = new IndexWriter(indexPath, getAnalyzer(),
							false, IndexWriter.MaxFieldLength.UNLIMITED);
				}

 

-- 查找索引目录下有没有文件,如果有则表示已经建立了索引,如果没有则新建索引。

分享到:
评论
3 楼 algorithm 2012-08-01  

这个是正解
2 楼 algorithm 2012-08-01  
似乎说错了...
false代表的是使用已有索引文件,如果没的话,会报no segments* file found in org.apache.lucene.store.FSDirectory
1 楼 yanjunshi 2011-07-14  

相关推荐

    基于JAVA的搜索引擎 lucene-2.2.0

    Exception in thread "main" java.io.FileNotFoundException: no segments* file found in org.apache.lucene.store.FSDirectory@E:\index: files: at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run...

    论文研究-Circle Segments 可视化技术应用研究 .pdf

    Circle Segments 可视化技术应用研究,程一博,胡俊,本文主要对Circle Segments可视化技术的应用做了研究。通过对比该技术在不同UCI数据集上的可视化结果,展示了其强大的可视化能力。通过

    c# 操作INI文件类

    private void TestINI_Load(object sender, System.EventArgs e) { //创建一个INIFile对象,参数为文件路径,如果不存在它会自动创建的 INIFile inf=new INIFile(@"D:\工作目录\VSPP\VSPPServer\bin\Debug\...

    c#操作ini文件

    private void TestINI_Load(object sender, System.EventArgs e) { //创建一个INIFile对象,参数为文件路径,如果不存在它会自动创建的 INIFile inf=new INIFile(@"D:\工作目录\VSPP\VSPPServer\bin\Debug\...

    MP3 Splitter & Joiner Pro v5.1+Keygen.rar

    - Supports to load audio files to split or merge in Windows Explorer directly: right-click the files (including *.cue, *. pls, *.m3u ), and select to open with MP3 Splitter & Joiner Pro in 'open with'...

    vox-5segments.pth.tar

    vox-5segments.pth.tar

    matlabtocarrecognition.rar_In the Making_matlab 车牌识别_杞︾墝瀹氫綅_车牌定位

    % segments in the result with largest area, and in case less than seven % segments were found, it attempts to recall the function, making the % separation between the already found segments clearer...

    Apache Hadoop 3.x state of the union and upgrade guidance

    Apache Hadoop YARN is the modern distributed operating system for big data applications. It morphed the Hadoop compute layer to be a common resource-management platform that can host a wide variety of...

    Python库 | decision-segments-0.1.0.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:decision-segments-0.1.0.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    Added TFlexFileFormat.StreamSupport property (default True), which difines, is it necessary to open file stream or give the file name only. - FIX: If the TCustomProp.Assign method calls when the ...

    Canvas撤回操作及前进功能(Javascript)

    * self.selectCanvas.getContext("2d").saveHistory(points, copy_segments, copy_rounds, copy_controlLine, * copy_selectedSegments, copy_selectedPoints); * 回撤及前进功能代码示例 * $(window).keydown...

    using-liferay-portal-6.2.pdf

    5.3 Alternative File Repository Options . . . . . . . . . . . . . . . . . . . . 119 5.4 Using External Repositories . . . . . . . . . . . . . . . . . . . . . . . . 119 5.5 Configuring the Documents ...

    greenplum-db-6.2.1-rhel7-x86_64.rpm

    The PXF_USER_IMPERSONATION, PXF_PRINCIPAL, and PXF_KEYTAB settings in the pxf-env.sh file. You can use the pxf-site.xml file to configure Kerberos and impersonation settings for your new Hadoop server...

    Nutch入门.rar

    1.4 nutch VS lucene.....2 2. nutch的安装与配置.....3 2.1 JDK的安装与配置.3 2.2 nutch的安装与配置........5 2.3 tomcat的安装与配置......5 3. nutch初体验7 3.1 爬行企业内部网....7 3.1.1 配置nutch.....

    Iczelion教程系列

    There's no more 64K segments. The memory is a large continuous space of 4 GB. That also means you don't have to play with segment registers. You can use any segment register to address any point in ...

    nutch 初学文档教材

    1.4 nutch VS lucene.....2 2. nutch的安装与配置.....3 2.1 JDK的安装与配置.3 2.2 nutch的安装与配置........5 2.3 tomcat的安装与配置......5 3. nutch初体验7 3.1 爬行企业内部网....7 3.1.1 配置nutch....7 ...

    Tricks of the Windows video Game Programming---part1

    Tricks of the Windows video Game Programming <br>PART I Windows Programming Foundations 7 1 Journey into the Abyss 9 A Little History.............................................................

    Sort Poems.cpp

    For example, the poem shown in Figure 1 is saved in two files as shown in Figure 2, provided that each file can only contain up to 4 lines. Notice that a blank line is also counted as a line in the ...

    kamon-example

    trace.segments.*.elapsed-time.upper_75Graphite 可以在 81 端口访问,为了获取容器的 ip,运行: docker inspect kamon-grafana-dashboard | grep IPAddress构建泊坞窗图像: sudo docker build -t akomar/kamon-...

    keras报错:ValueError: Cannot create group in read only mode

    keras保存模型时,使用的是m.save_weights,只保存了模型的权重而没有结构,直接使用keras.models.load_model就会报错。所以,可以重新构建相同结构的模型,(m.save_weights)使用m.load_weights;...

Global site tag (gtag.js) - Google Analytics