Lucene Index从4.6版本升级到8.0.0

时间:2019-09-26 10:37:41

标签: java lucene

我正在尝试将Lucene索引从4.6升级到8.0.0。当我尝试使用以下工具升级工具时:

java -cp lucene-core.jar:lucene-backward-codecs.jar \
 org.apache.lucene.index.IndexUpgrader -delete-prior-commits  \
/scratch/***/workspaces/trunk/****/indexes/4.6/

脚本从4.65.5.55.5.56.6.66.6.67.7.2正常工作。但是,当我尝试从7.7.2升级到8.0.0时,会引发如下错误。

Exception in thread "main" org.apache.lucene.index.IndexFormatTooOldException: Format version is not supported (resource BufferedChecksumIndexInput(MMapIndexInput(path="/scratch/**/workspaces/trunk/**/indexes/4.6/sd/segments_9"))): This index was initially created with Lucene 6.x while the current version is 8.0.0 and Lucene only supports reading the current and previous major versions.. This version of Lucene only supports indexes created with release 7.0 and later.
    at org.apache.lucene.index.SegmentInfos.readCommit(SegmentInfos.java:318)
    at org.apache.lucene.index.SegmentInfos.readCommit(SegmentInfos.java:289)
    at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:846)
    at org.apache.lucene.index.IndexUpgrader.upgrade(IndexUpgrader.java:167)
    at org.apache.lucene.index.IndexUpgrader.main(IndexUpgrader.java:78)

我们想从4.6升级到8.0.0。直到7.7.2都在升级,没有任何问题,但是当我在代码索引中使用Lucene版本7.7.2时工作正常。但是Lucene 8.0.0无法正常工作。

请帮助我升级8.0.0

1 个答案:

答案 0 :(得分:0)

  1. 如果要升级多个主要版本,则必须重新编制索引。
  2. 一直不鼓励进行多个主要版本的升级,并且从不保证可以进行任何操作,但是现在明确拒绝了此类升级。
  3. 当我们使用Lucene 6中的IndexUpgrader时,Lucene版本被写入到索引中。记录的版本由升级程序保留为版本7。当版本8随后读取该索引时,它抱怨是因为原始索引不是由版本7或更高版本编写的。