Sitecore 8根据索引搜索提供特定标记的页面
我正在从8.1升级到8.2更新3。我知道搜索/索引已更改,一些代码已过时或不再有效 不幸的是,在我们的一个类项目中,我们的sitecore合作伙伴为我们构建的一些方法由于过时的代码而不再有效,现在我需要帮助更新这些代码。我已经能够用一些简单的代码将它缩小到只有2个文件 以下是第一组代码:Sitecore 8根据索引搜索提供特定标记的页面,sitecore,sitecore8,Sitecore,Sitecore8,我正在从8.1升级到8.2更新3。我知道搜索/索引已更改,一些代码已过时或不再有效 不幸的是,在我们的一个类项目中,我们的sitecore合作伙伴为我们构建的一些方法由于过时的代码而不再有效,现在我需要帮助更新这些代码。我已经能够用一些简单的代码将它缩小到只有2个文件 以下是第一组代码: public partial class TagResults { /// <summary> /// Searches against the Lucene index for p
public partial class TagResults
{
/// <summary>
/// Searches against the Lucene index for pages given a specific tag
/// </summary>
/// <returns></returns>
public List<BasePage> GetPagesForTag(string Tag, int page, int pageSize, out int totalCount)
{
var tags = new List<BasePage>();
Index searchIndex = SearchManager.GetIndex(Constants.LuceneIndexes.Tags);
using (IndexSearchContext context = searchIndex.CreateSearchContext())
{
//The wildcard search allows us to pull back all items with the given tag
var query = new WildcardQuery(new Term(Constants.LuceneFields.Tags, Tag));
SearchHits hits = context.Search(query);
totalCount = hits.Length;
//Go through the results
SearchResultCollection results = hits.FetchResults(page * pageSize, pageSize);
foreach (SearchResult result in results)
{
var searchItem = result.GetObject<Item>();
Item currentDbItem = ItemUtility.GetItem(searchItem.ID);
//Store the item if it exists and is a descendant of the news listing
if (currentDbItem != null)
{
tags.Add(new BasePage(currentDbItem));
}
}
}
return tags.ToList();
}
public static bool IsItemCastable(Item sitecoreItem)
{
return sitecoreItem != null && !string.IsNullOrEmpty(sitecoreItem[FieldIds.IsTagResultsComponent]);
}
}
但后来我就被卡住了
SearchHits hits = context.Search(query);
totalCount = hits.Length;
//Go through the results
SearchResultCollection results = hits.FetchResults(page * pageSize, pageSize);
foreach (SearchResult result in results)
现在我要求很多,但我正在学习。如果有人能帮我纠正这一点,我将非常感激。我已经做了很多搜索,试图找出如何纠正这一点,但我觉得我错过了一些东西,我只是需要一些帮助
先谢谢你
SearchHits hits = context.Search(query);
totalCount = hits.Length;
//Go through the results
SearchResultCollection results = hits.FetchResults(page * pageSize, pageSize);
foreach (SearchResult result in results)