Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

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

Indexing related content

Sometimes, to preserve consistency in the index, it is necessary to index not only saved/published content but also related content. For example, you indexed the child count for content and want it updated whenever "child content" is published.

Examples

To index related content, set the RelatedContent convention to return parent content when indexing. This way, parent content is reindexed and its child count is 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;
  });

Last updated: Nov 16, 2015