London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Navigation [hide] [expand]
Area: Optimizely Search & Navigation
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Introduction

Sometimes it is necessary to index not only the saved/published content, but also related content to preserve consistency in the index. One such case may be if we have indexed the child count for content and want to have it updated whenever "child content" is published.

Examples

To index related content, we set the RelatedContent convention to return the parent content when indexing. This way the parent content will be reindexed and its child count updated.

C#
ContentIndexer.Instance.Conventions
  .ForInstancesOf<IContent>()
  .RelatedContent(x =>
  {
    var relatedContent = new List<IContent>();
    if (!(x.ContentLink.CompareToIgnoreWorkID(ContentReference.StartPage) || 
         x.ContentLink.CompareToIgnoreWorkID(Contentference.RootPage)))
    {
      relatedContent.Add(DataFactory.Instance.Get<IContent>(x.ParentLink));
    }
    return relatedContent;
  });

Note that this functionality is not related to finding content with similar or related content. For such functionality, refer to the MoreLike method described in the Searching section of this documentation.

Last updated: Sep 21, 2015