We recently upgraded to Sitecore 6.6 and are running into issues with the search and crawl functionality from Lucene since 6.6 uses a newer version and has some of the methods/functions have been made obsolete.
The code below used to work fine with the previous version of Lucene.NET 2.3 but isn't working in 2.9. Can you tell us what we are doing wrong and help us rectify this piece of code? The error we get while compiling is
`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?)
This error happens on this line - Sitecore.Search.SearchHits hits = new SearchHits(context.Searcher.Search(query,sort));
. I'm guessing that it will be a simple fix but I'm unsure of how to go about fixing it.
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;
}
Thanks