为什么可以';t Luke(4.0.0-ALPHA)打开Lucene4.0';s索引文件?
我使用Lucene4.0制作索引文件:为什么可以';t Luke(4.0.0-ALPHA)打开Lucene4.0';s索引文件?,lucene,luke,Lucene,Luke,我使用Lucene4.0制作索引文件: File directorycreate = new File(indexpath); Directory dir = new SimpleFSDirectory(directorycreate); Analyzer analyzer = new IKAnalyzer(true); IndexWriterConfig conf = new In
File directorycreate = new File(indexpath);
Directory dir = new SimpleFSDirectory(directorycreate);
Analyzer analyzer = new IKAnalyzer(true);
IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_40, analyzer);
IndexWriter writer = new IndexWriter(dir,conf);
Document document = new Document();
FieldType fieldtype = new FieldType();
fieldtype.setIndexed(true);
fieldtype.setTokenized(true);
fieldtype.setStored(true);
fieldtype.setStoreTermVectorPositions(true);
fieldtype.setStoreTermVectors(true);
document.add(new Field("title",name,fieldtype));
document.add(new Field("content",description,fieldtype));
document.add(new Field("contenttype", "product",TextField.TYPE_STORED));
document.add(new Field("doctype","product",TextField.TYPE_STORED));
This is my index files:
2013/01/03 10:49 <DIR> .
2013/01/03 10:49 <DIR> ..
2013/01/03 10:49 20 segments.gen
2013/01/03 10:49 69 segments_1
2013/01/03 10:49 16,566,094 _0.fdt
2013/01/03 10:49 526,786 _0.fdx
2013/01/03 10:49 459 _0.fnm
2013/01/03 10:49 357 _0.si
2013/01/03 10:49 307,358 _0.tvd
2013/01/03 10:49 17,926,810 _0.tvf
2013/01/03 10:49 1,053,537 _0.tvx
2013/01/03 10:49 2,946,878 _0_Lucene40_0.frq
2013/01/03 10:49 2,548,982 _0_Lucene40_0.prx
2013/01/03 10:49 18,903 _0_Lucene40_0.tim
2013/01/03 10:49 332 _0_Lucene40_0.tip
2013/01/03 10:49 165 _0_nrm.cfe
2013/01/03 10:49 329,336 _0_nrm.cfs
File directorycreate=新文件(indexpath);
Directory dir=new SimpleFSDirectory(directorycreate);
分析仪=新的IKAnalyzer(真);
IndexWriterConfig conf=新的IndexWriterConfig(Version.LUCENE_40,analyzer);
IndexWriter=新的IndexWriter(dir,conf);
文档=新文档();
FieldType FieldType=新的FieldType();
fieldtype.setIndexed(true);
fieldtype.setTokenized(true);
字段类型。设置存储(真);
fieldtype.setStoreTermVectorPositions(真);
fieldtype.setStoreTermVectors(真);
添加(新字段(“标题”、名称、字段类型));
添加(新字段(“内容”、说明、字段类型));
添加(新字段(“contenttype”、“product”、TextField.TYPE_存储));
添加(新字段(“doctype”、“product”、TextField.TYPE_存储));
这是我的索引文件:
2013/01/03 10:49 .
2013/01/03 10:49 ..
2013/01/03 10:49 20.gen
2013/01/03 10:49 69第1节
2013/01/03 10:49 16566094 _0.fdt
2013/01/03 10:49 526786 _0.fdx
2013/01/03 10:49 459 _0.fnm
2013/01/03 10:49 357 _0.si
2013/01/03 10:49 307358
2013/01/03 10:49 17926810 0.tvf
2013/01/03 10:49 1053537 _0.tvx
2013/01/03 10:49 2946878 _0_Lucene40_0.frq
2013/01/03 10:49 2548982_0_Lucene40_0.prx
2013/01/03 10:49 18903(Lucene40)
2013/01/03 10:49 332 Lucene40
2013/01/03 10:49 165
2013/01/03 10:49 329336
但是lukeall-4.0.0-ALPHA.jar
(http://code.google.com/p/luke/downloads/list)无法打开这些索引文件,出现错误:
不支持格式版本(资源:SimpleFSIndexInput(path=“D:\myProjectPro\Java\createIndex\product\u 0.tvx”):1(需要介于0和0之间)
有什么想法吗?
提前感谢。我猜这个问题是版本不匹配。看起来最新的Luke-lukeall-4.0.0-ALPHA只使用Lucene 4.0 ALPHA位构建(2012年7月),我假设您正在使用Lucene 4.0官方版本(2012年10月)创建索引。我认为在这一点上,你有两种可能的选择:
我对Luke不太熟悉,但看起来这个版本的Luke是在term vectors支持的有效载荷之前构建的(当tvx版本号从0增加到1时),请参见。谢谢你的回答。我明白你的意思,但我是Luke的乞丐。所以我仍然不知道如何解决这个问题。我只是等待Luke的新版本:)此外,由于您的回答可能是版本不匹配,而且lukeall-4.0.0-ALPHA.jar似乎不支持索引文件的术语向量选项,因此可以通过Luke4.0 APLHA打开索引文件,如果我构建索引文件时没有使用术语向量选项。感谢您的更新,有关术语向量支持的详细信息,请参阅@jpountz的答案。感谢您提醒我。我会仔细阅读那些材料。