我正在尝试为Developer's Guide to Item Buckets and Search的第5.7.2节中描述的字段实施基于规则的提升。我已经使用这些包含复制了代码行,所以整个类文件看起来像:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sitecore.ContentSearch.Pipelines.ResolveBoost.ResolveFieldBoost;
using Sitecore.Diagnostics;
using Sitecore.ContentSearch.Boosting;
using Sitecore;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.Diagnostics;
namespace MyNamespace.Pipeline
{
public class RuleBasedFieldBoostResolver : BaseResolveFieldBoostPipelineProcessor
{
public override void Process(ResolveFieldBoostArgs args)
{
Assert.ArgumentNotNull(args, "args");
Assert.ArgumentNotNull(args.FieldDefinitionItem, "field definition item");
var fieldItem = args.FieldDefinitionItem;
var ruleContext = new RuleBoostingContext(fieldItem);
var ruleItems = this.GetLocalBoostingRules(fieldItem);
if (ruleItems == null || !ruleItems.Any())
{
CrawlingLog.Log.Debug(string.Format("No local rules were resolved for field {0}", fieldItem.Uri));
return;
}
var rules = this.ConvertToBoostingRules<RuleBoostingContext>(ruleItems);
try
{
if (rules != null)
{
rules.Run(ruleContext);
}
}
catch (Exception exception)
{
CrawlingLog.Log.Error(string.Format("Cannot resolve boost for item {0}.", fieldItem.Uri), exception);
}
args.ResolvedBoost += ruleContext.Boost;
}
}
}
但是,我收到错误:ResolveFieldBoostArgs does not contain a definition for 'FieldDefinitionItem'
。
任何想法我都缺少什么?
由于 萨德
答案 0 :(得分:0)
交换此行:
var fieldItem = args.FieldDefinitionItem;
作为强>
var fieldItem = (Item)args.FieldDefinition;