我們最近升級到Sitecore 6.6,並且由於6.6使用更新的版本並且已經使一些方法/功能過時而遇到來自Lucene的搜索和爬取功能的問題。Sitecore 6.6和Lucene升級問題
以下代碼用於與以前版本的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 = new SearchHits(context.Searcher.Search(query,sort));
。我猜這將是一個簡單的修復,但我不確定如何去修復它。
private static SearchResultCollection GetSearchResults(Query query, Sort sort, int startingIndex, int getCount, out int totalHits)
{
SearchResultCollection retVal = new SearchResultCollection();
Sitecore.Search.Index searchIndex = Sitecore.Search.SearchManager.GetIndex("content");
using (Sitecore.Search.IndexSearchContext context = searchIndex.CreateSearchContext())
{
Sitecore.Search.SearchHits hits = new SearchHits(context.Searcher.Search(query,sort));
totalHits = hits.Length;
//since index is zero based... adjust the numbers
startingIndex = (startingIndex - 1) * getCount;
getCount = (getCount > totalHits || totalHits < startingIndex + getCount)
? hits.Length - startingIndex : getCount;
retVal = hits.FetchResults(startingIndex, getCount);
}
return retVal;
}
感謝
發生了變化。在洞裏射擊! :) – Gabbar
隨着你的代碼,我得到了以下錯誤 - prefixCoded字符串中的無效移位值(編碼值真的是INT?) – Gabbar
任何stacktrace?剛剛在谷歌上找到一個和你有同樣問題的人,他的回答是「我爲數字字段索引了一個double,但我的Sortfield被設置爲一個浮點數。」 –