public virtual object ComputeFieldValue(IIndexable indexable) { if (!(indexable is SitecoreIndexableItem indexableItem)) { return(null); } var index = ContentSearchManager.GetIndex(indexable); if (index == null) { return(null); } var config = Factory.CreateObject("kotoha/configuration", false) as KeywordSearchConfiguration; if (config == null) { return(null); } var searchTarget = config.GetSearchTargetById(SearchTargetId); if (searchTarget == null) { return(null); } var fieldValues = searchTarget.Fields .Select(field => indexable.GetFieldByName(field.Name)) .Where(field => field != null) .Select(field => index.Configuration.FieldReaders.GetFieldValue(field)?.ToString()) .Where(value => !string.IsNullOrWhiteSpace(value)); return(string.Join(" ", fieldValues)); }
public static string GetFieldValueAsString(this IIndexable indexable, string fieldName) { var field = indexable.GetFieldByName(fieldName); return(field != null ? field.Value as string : string.Empty); }
protected override object Compute(IIndexable indexable) => indexable?.GetFieldByName(Constants.Fields.Redirect.Target)?.Value;