public void Process(ComputedSearchPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); Assert.ArgumentNotNull(args.CurrentItem, "args.CurrentItem"); args.ComputedContent = StripTagsCharArray(args.ComputedContent); }
public void Process(ComputedSearchPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); Assert.ArgumentNotNull(args.CurrentItem, "args.CurrentItem"); args.ComputedContent = ItemContent(args); }
public void Process(ComputedSearchPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); if (args.CrawlerFieldMap.ScopeItemId.IsNullOrEmpty()) { args.AbortPipeline(); } }
public void Process(ComputedSearchPipelineArgs args) { Assert.ArgumentNotNull(args, "args"); if (args.CurrentItem.HasPresentationDetails() && args.CurrentItem.Paths.LongID.Contains(args.CrawlerFieldMap.ScopeItemId)) { return; } if (!args.CrawlerFieldMap.AllowNoPresentation && !args.CurrentItem.Paths.LongID.Contains(args.CrawlerFieldMap.ScopeItemId)) { args.AbortPipeline(); } }
public override object ComputeFieldValue(IIndexable indexable) { Item item = ComputedHelper.QuitEarlyIfPossible(indexable); if (item != null) { var pipelineArgs = new ComputedSearchPipelineArgs { CurrentItem = item, CrawlerFieldMap = CrawlerFieldMap }; CorePipeline.Run("Arke.Sitecore.ComputedSearch.ComputePresentation", pipelineArgs); return pipelineArgs.ComputedContent; } return string.Empty; }
/// <summary> /// Crawls fields on an item and includes their content in the index /// </summary> public static string ItemContent(ComputedSearchPipelineArgs args) { var result = new StringBuilder(); args.CurrentItem.Fields.ReadAll(); foreach (var field in args.CurrentItem.Fields.Where(ShouldIndexField)) { if (args.CrawlerFieldMap.TemplateFieldNames.ToLowerInvariant() .Split('|') .Contains(field.Name.ToLowerInvariant())) { if (args.CrawlerFieldMap.DebugMode) { Log.Info( string.Format("[Computed Search] '{0}' field name match found for item '{1}' of template type '{2}'", field.Name, args.CurrentItem.Name, args.CurrentItem.TemplateName), typeof(GetItemContent)); } result.AppendLine(field.Value); } } return result.ToString(); }
/// <summary> /// Crawls the renderings on an item and includes their content in the index /// </summary> public static string VisualizationContent(ComputedSearchPipelineArgs args) { IEnumerable<Item> dataSources = args.CurrentItem.GetVisualizationDatasources(); var result = new StringBuilder(); foreach (var dataSource in dataSources) { //Check datasource item if (args.CrawlerFieldMap.CrawlerFieldMappings.Any(t => t.TemplateId.Equals(dataSource.TemplateID.ToString()))) { if (args.CrawlerFieldMap.DebugMode) { global::Sitecore.Diagnostics.Log.Info( string.Format("[Computed Search] {0} dataSources found for item '{1}' that match template '{2}'", dataSources.Count(), args.CurrentItem.Name, dataSource.TemplateID), typeof(GetVisualizationContent)); } dataSource.Fields.ReadAll(); foreach (var field in dataSource.Fields.Where(ShouldIndexField)) { if ( args.CrawlerFieldMap.CrawlerFieldMappings.Any( t => t.TemplateFieldNames.ToLowerInvariant() .Split('|') .Contains(field.Name.ToLowerInvariant()))) { result.AppendLine(field.Value); } } } //Special case for when you have a datasource item that is referencing other items dataSource.Fields.ReadAll(); foreach (var field in dataSource.Fields.Where(ShouldIndexField)) { //Possibly to a check for certain field types here var fieldItemValues = field.Value.Split('|'); foreach (var targetItemId in fieldItemValues) { var targetItem = Factory.GetDatabase("master").GetItem(targetItemId); if (targetItem == null) { continue; } if (!args.CrawlerFieldMap.CrawlerFieldMappings.Any( t => t.TemplateId.Equals(targetItem.TemplateID.ToString()))) { continue; } targetItem.Fields.ReadAll(); foreach (var targetField in targetItem.Fields.Where(ShouldIndexField)) { if (!args.CrawlerFieldMap.CrawlerFieldMappings.Any( t => t.TemplateFieldNames.ToLowerInvariant() .Split('|') .Contains(targetField.Name.ToLowerInvariant()))) { continue; } if (args.CrawlerFieldMap.DebugMode) { global::Sitecore.Diagnostics.Log.Info( string.Format("[Computed Search] '{0}' field name match found items referenced by datasource of item '{1}' of template type '{2}'", targetField.Name, args.CurrentItem.Name, targetItem.TemplateName), typeof(GetVisualizationContent)); } result.AppendLine(targetField.Value); } } } //Check datasource item descendents foreach (var childItem in dataSource.Axes.GetDescendants()) { if (args.CrawlerFieldMap.CrawlerFieldMappings.Any(t => t.TemplateId.Equals(childItem.TemplateID.ToString()))) { if (args.CrawlerFieldMap.DebugMode) { global::Sitecore.Diagnostics.Log.Info( string.Format("[Computed Search] {0} dataSources found for the descendents of item '{1}' that match template '{2}'", dataSources.Count(), args.CurrentItem.Name, dataSource.TemplateName), typeof(GetVisualizationContent)); } childItem.Fields.ReadAll(); foreach (var field in childItem.Fields.Where(ShouldIndexField)) { if ( args.CrawlerFieldMap.CrawlerFieldMappings.Any( t => t.TemplateFieldNames.ToLowerInvariant() .Split('|') .Contains(field.Name.ToLowerInvariant()))) { if (args.CrawlerFieldMap.DebugMode) { global::Sitecore.Diagnostics.Log.Info( string.Format("[Computed Search] '{0}' field name match found for the descendents of item '{1}' of template type '{2}'", field.Name, args.CurrentItem.Name, dataSource.TemplateName), typeof(GetVisualizationContent)); } result.AppendLine(field.Value); } } } } } return result.ToString(); }