简体   繁体   English

如何使用lucene.net查询Solr索引

[英]how to use lucene.net to query a solr index

I have and index created using solr DIH. 我已经使用Solr DIH创建了索引。 I want to query that index data using the Lucene.net library. 我想使用Lucene.net库查询该索引数据。

the path of solr index is D:\\Tests\\solr\\example\\example-DIH\\solr\\db\\data\\index Solr索引的路径为D:\\ Tests \\ solr \\ example \\ example-DIH \\ solr \\ db \\ data \\ index

the code I use to create lucene index directory object is as follows: 我用来创建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);

while executing the last line of code I get the following exception: 在执行最后一行代码时,出现以下异常:

Could not find file 'D:\\Tests\\solr\\example\\example-DIH\\solr\\db\\data\\index\\segments'. 找不到文件“ D:\\ Tests \\ solr \\ example \\ example-DIH \\ solr \\ db \\ data \\ index \\ segments”。

Given that the files within my solr index folder are 鉴于我的solr索引文件夹中的文件是

  • _0.fdt _0.fdt
  • _0.fdx _0.fdx
  • _0.fnm _0.fnm
  • _0.frq _0.frq
  • _0.nrm _0.nrm
  • _0.prx _0.prx
  • _0.tii _0.tii
  • _0.tis _0.tis
  • segments.gen segments.gen
  • segments_2 segment_2

So what is the problem?? 那是什么问题呢?

Lucene.NET is only up to Lucene version 2.9.2.2 or so while solr is running on Lucene 2.9.3. 当solr在Lucene 2.9.3上运行时,Lucene.NET只能使用Lucene 2.9.2.2或更高版本。 This means that Lucene.NET can't index a SOLR index so easily. 这意味着Lucene.NET不能这么轻松地为SOLR索引建立索引。

Now, what you can do is use something like SolrSharp to access Solr directly, sidestepping this version issue. 现在,您可以做的是使用SolrSharp之类的东西直接访问Solr,避开此版本问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM