1

I contacted Sitecore Support for the issue and this was the solution given. Our website has a lot of link lists throughout the site. We noticed that link lists are not being searched (the link text), so I was told I needed to extend the AggregatedContent.cs class and add a config file to add it to my website. The class is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sitecore.Data.Fields;
using Sitecore.Data.Items;
using Sitecore.Layouts;
using Sitecore.Text;

namespace BXS.XA.Foundation.Custom.Search
{
    public class AggregatedContent : Sitecore.XA.Foundation.Search.ComputedFields.AggregatedContent
    {
        protected override IEnumerable<Item> GetLayoutReferences(Item item, ISet<Item> dataFolders)
        {
            LayoutField layoutField = new LayoutField(item);
            using (new ContextItemSwitcher(item))
            {
                DeviceItem[] all = item.Database.Resources.Devices.GetAll();
                foreach (DeviceItem device in all)
                {
                    IEnumerable<RenderingReference> references = layoutField.GetReferences(device);
                    foreach (RenderingReference item3 in references ?? Enumerable.Empty<RenderingReference>())
                    {
                        string[] items = new ListString(item3.Settings.DataSource ?? string.Empty).Items;
                        foreach (string path in items)
                        {
                            Item item2 = item.Database.GetItem(path, item.Language, Sitecore.Data.Version.Latest);
                            if (item2 != null && IsDataItem(item2, dataFolders))
                            {
                                // custom - start
                                if (item2.TemplateName == "Link List")
                                {
                                    foreach (Item linkItem in item2.Children)
                                    {
                                        var field = (LinkField)linkItem.Fields["Link"];
                                        if (field.IsInternal)
                                        {
                                            yield return field.TargetItem;
                                        }
                                    }
                                }
                                // custom - end
                                yield return item2;
                            }
                        }
                    }
                }
            }
        }
    }
}

The config file is:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
  <sitecore>
    <contentSearch search:require="solr">
      <indexConfigurations>
        <defaultSolrIndexConfiguration>
          <documentOptions>
            <fields hint="raw:AddComputedIndexField">
              <field fieldName="sxacontent">
                <patch:delete />
              </field>
              <field fieldName="sxacontent" returnType="textCollection" type="BXS.XA.Foundation.Custom.Search.AggregatedContent, BXS.XA.Foundation.Custom.Search">
                <mediaIndexing ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration/mediaIndexing"/>
              </field>
            </fields>
          </documentOptions>
        </defaultSolrIndexConfiguration>
      </indexConfigurations>
    </contentSearch>
  </sitecore>
</configuration>

I've checked showconfig.aspx to make sure this code is being included and it is. I rebuilt my indexes, and the link lists are still not showing up when I search the text of one of the links.

13
  • Hello, are you sure that your field tag in the configuration is correct? Mar 19 at 14:03
  • Did you try to debug this code due to reindex? Mar 19 at 14:05
  • @VadimBirkos How can I debug a class library with Sitecore? And I'm not sure if the field tag is correct but it's what Sitecore Support gave me. What part of it do you think I might need to change? Mar 19 at 14:12
  • As I understood BXS.XA.Foundation.Custom.Search.AggregatedContent contains in your solution and you can check if the crawler reached this place due Re-Index. Here instructions how to Debug not your DLLs in Visual Studio. stackoverflow.com/questions/654696/… Mar 19 at 14:32
  • Alright, so I just need to put a stop on my code in my class. Do I need to do a reindex to hit it or just search for something? Sorry I got this code from Sitecore Support and am not entirely sure what it does. Mar 19 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.