1

我使用Lucene4.0制作索引文件:

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

但是 lukeall-4.0.0-ALPHA.jar (http://code.google.com/p/luke/downloads/list) 无法打开这些索引文件,出现错误:不支持格式版本(资源:SimpleFSIndexInput (path="D:\myProjectPro\Java\createIndex\product_0.tvx")):1(需要在 0 和 0 之间)。

有任何想法吗?提前致谢。

4

2 回答 2

0

我对 Luke 不是很熟悉,但看起来这个版本的 Luke 是在术语向量支持有效负载之前构建的(当 tvx 版本号从 0 上升到 1 时),请参阅https://issues.apache.org/jira/浏览/LUCENE-1888

于 2013-01-03T14:44:38.227 回答
0

我猜这个问题是版本不匹配。看起来最新的 Luke - lukeall-4.0.0-ALPHA 仅使用 Lucene 4.0 ALPHA 位(2012 年 7 月)构建,我假设您正在使用官方 Lucene 4.0 版本(2012 年 10 月)来创建索引。我认为此时您有两种可能的选择:

  1. 使用 Lucene 4.0 ALPHA 创建索引 - 从Lucene Archives获取 jars 。
  2. 似乎是 BETA 版本的 Luke 签入源代码 -更改 r86。拉取最新源代码,在本地构建 Luke 并试用 BETA 版本。
于 2013-01-03T13:13:56.863 回答