【发布时间】:2021-01-28 18:31:13
【问题描述】:
使用(最新的)lucene 8.7 是否可以使用 lucene 实用程序“Luke”在我无法修改的旧应用程序中打开由 2009 年左右的 lucene 2.2 生成的 .cfs 复合索引文件?
或者,是否可以从 .cfs 为 Luke 生成 .idx 文件?
.cfs 是在 lucene 2.2 之上由 compass 生成的,而不是由 lucene 直接生成的
是否可以使用包含以下内容的指南针生成的索引:
_b.cfs
段.gen
段_d
可能与 solr 一起使用?
是否有任何示例如何在任何地方使用指南针打开基于文件的 .cfs 索引?
转换工具无法使用,因为索引版本太旧:
来自 lucene\build\demo:
java -cp ../core/lucene-core-8.7.0-SNAPSHOT.jar;../backward-codecs/lucene-backward-codecs-8.7.0-SNAPSHOT.jar org.apache.lucene.index .IndexUpgrader -verbose path_of_old_index
还有搜索文件演示:
java -classpath ../core/lucene-core-8.7.0-SNAPSHOT.jar;../queryparser/lucene-queryparser-8.7.0-SNAPSHOT.jar;./lucene-demo-8.7.0- SNAPSHOT.jar org.apache.lucene.demo.SearchFiles -index path_of_old_index
都失败了:
org.apache.lucene.index.IndexFormatTooOldException:不支持格式版本 此版本的 Lucene 仅支持使用 6.0 及更高版本创建的索引。
是否可以以某种方式将旧索引与 lucene 一起使用?如何使用旧的“编解码器”? 如果可能,也来自 lucene.net?
当前的 lucene 8.7 生成一个包含这些文件的索引:
segments_1
写锁
_0.cfe
_0.cfs
_0.si
================================================ ============================ 更新:令人惊讶的是,它似乎用 nuget 的 lucene.net v. 3.0.3 打开了那个非常旧的格式索引!
这似乎可以从索引中提取所有术语:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using Lucene.Net.Analysis.Standard;
using Lucene.Net.Documents;
using Lucene.Net.Index;
using Lucene.Net.QueryParsers;
using Lucene.Net.Search;
using Lucene.Net.Store;
using Version = Lucene.Net.Util.Version;
namespace ConsoleApplication1
{
class Program
{
static void Main()
{
var reader = IndexReader.Open(FSDirectory.Open("C:\\Temp\\ftsemib_opzioni\\v210126135604\\index\\search_0"), true);
Console.WriteLine("number of documents: "+reader.NumDocs() + "\n");
Console.ReadLine();
TermEnum terms = reader.Terms();
while (terms.Next())
{
Term term = terms.Term;
String termField = term.Field;
String termText = term.Text;
int frequency = reader.DocFreq(term);
Console.WriteLine(termField +" "+termText);
}
var fieldNames = reader.GetFieldNames(IndexReader.FieldOption.ALL);
int numFields = fieldNames.Count;
Console.WriteLine("number of fields: " + numFields + "\n");
for (IEnumerator<String> iter = fieldNames.GetEnumerator(); iter.MoveNext();)
{
String fieldName = iter.Current;
Console.WriteLine("field: " + fieldName);
}
reader.Close();
Console.ReadLine();
}
}
}
出于好奇,是否有可能找出它是什么索引版本? 有没有基于文件系统索引的(旧)指南针示例?
【问题讨论】:
标签: lucene lucene.net compass