Sitecore 6.6和Lucene升级问题

Sitecore 6.6和Lucene升级问题,lucene,sitecore,lucene.net,sitecore6,Lucene,Sitecore,Lucene.net,Sitecore6,我们最近升级到Sitecore 6.6,并且在Lucene的搜索和爬网功能方面遇到了问题,因为6.6使用了更新的版本,并且一些方法/功能已经过时 下面的代码过去在Lucene.NET 2.3的早期版本中运行良好,但在2.9中不起作用。你能告诉我们我们做错了什么并帮助我们纠正这段代码吗?编译时出现的错误是 `Lucene.Net.Search.IndexSearcher` does not contain a definition for 'Search' and no extension met

我们最近升级到Sitecore 6.6,并且在Lucene的搜索和爬网功能方面遇到了问题,因为6.6使用了更新的版本,并且一些方法/功能已经过时

下面的代码过去在Lucene.NET 2.3的早期版本中运行良好,但在2.9中不起作用。你能告诉我们我们做错了什么并帮助我们纠正这段代码吗?编译时出现的错误是

`Lucene.Net.Search.IndexSearcher` does not contain a definition for 'Search'
and no extension method 'Search' accepting a first argument of type 
`Lucene.Net.Search.IndexSearcher` could be found (are you missing a using 
directive or an assembly reference?) 
此错误发生在此行-
Sitecore.Search.SearchHits hits=newsearchhits(context.Searcher.Search(query,sort))。我猜这将是一个简单的修复,但我不确定如何着手修复它

私有静态SearchResultCollection GetSearchResults(查询查询、排序、int startingIndex、int getCount、out int totalHits)
{
SearchResultCollection retVal=新的SearchResultCollection();
Sitecore.Search.Index searchIndex=Sitecore.Search.SearchManager.GetIndex(“内容”);
使用(Sitecore.Search.IndexSearchContext上下文=searchIndex.CreateSearchContext())
{
Sitecore.Search.SearchHits hits=新的SearchHits(context.Searcher.Search(查询,排序));
totalHits=点击次数。长度;
//由于索引是基于零的…请调整数字
startingIndex=(startingIndex-1)*getCount;
getCount=(getCount>totalHits | | totalHits

谢谢

不太熟悉Sitecore,但是
Searcher.search(查询、排序)
在Lucene 2.9中被弃用,看起来在Lucene.Net中根本不存在。相反,打电话。第二个参数(Filter)可以为null,第三个参数(int)表示从搜索返回的文档数。

Sitecore 6.6使用Lucene 2.9。下面的代码是更新后的代码,以支持更新版本的Lucene。有两大变化:

  • Search
    方法使用两个附加参数执行(
    Filter
    设置为
    null
    maxDocs
    设置为
    int.MaxValue
  • SearchHits
    构造函数将
    IndexReader
    实例作为第二个参数
  • 下面的代码应该完全按照您的预期工作

    使用(Sitecore.Search.IndexSearchContext=searchIndex.CreateSearchContext())
    {
    TopFieldDocs=context.Searcher.Search(query,null,int.MaxValue,sort);
    Sitecore.Search.SearchHits hits=新的SearchHits(docs,context.Searcher.GetIndexReader());
    totalHits=点击次数。长度;
    startingIndex=(startingIndex-1)*getCount;
    getCount=(getCount>totalHits | | totalHits
    进行了更改。洞里有火!:)对于您的代码,我得到了以下错误-预编码字符串中的移位值无效(编码值真的是INT吗?)是否有堆栈跟踪?刚在谷歌上发现一个家伙和你有同样的问题,他的回答是“我为数字字段建立了一个双精度索引,但我的Sortfield设置为一个float。”我可以用你的代码让它工作。我收到的错误位于未正确索引的字段上。一旦我解决了这个问题,一切都开始起作用了。再次感谢您的投入。