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));
        }
Ejemplo n.º 2
0
        public static string GetFieldValueAsString(this IIndexable indexable, string fieldName)
        {
            var field = indexable.GetFieldByName(fieldName);

            return(field != null ? field.Value as string : string.Empty);
        }
Ejemplo n.º 3
0
 protected override object Compute(IIndexable indexable) => indexable?.GetFieldByName(Constants.Fields.Redirect.Target)?.Value;