0

我已经使用 solr DIH 创建了索引。我想使用 Lucene.net 库查询该索引数据。

solr 索引的路径是 D:\Tests\solr\example\example-DIH\solr\db\data\index

我用来创建 lucene 索引目录对象的代码如下:

Analyzer anz = new StandardAnalyzer();
Directory dir = 
 FSDirectory.GetDirectory(@"D:\Tests\solr\example\example DIH\solr\db\data\index", false);
IndexSearcher isearcher = new IndexSearcher(dir);

在执行最后一行代码时,出现以下异常:

找不到文件“D:\Tests\solr\example\example-DIH\solr\db\data\index\segments”。

鉴于我的 solr 索引文件夹中的文件是

  • _0.fdt
  • _0.fdx
  • _0.fnm
  • _0.frq
  • _0.nrm
  • _0.prx
  • _0.tii
  • _0.tis
  • 段.gen
  • 段_2

那么问题出在哪里??

4

1 回答 1

0

Lucene.NET 只能达到 Lucene 2.9.2.2 版左右,而 solr 在 Lucene 2.9.3 上运行。这意味着 Lucene.NET 不能那么容易地索引 SOLR 索引。

现在,您可以做的是使用SolrSharp 之类的东西直接访问 Solr,避开这个版本问题。

于 2011-03-13T13:44:56.617 回答