Thursday, March 17, 2016

Sitecore Lucene serach indexing sublayout or rendering data sources

Most Sitecore sites will use renderings or sublayouts in Sitecore as a method to display data, and more often than not the data is a custom template assigned via data source. It's this sort of logic which could then be extended to personalize or A/B test which content works best. The only trouble is ensuring that this content is able to be added to the Lucene search index against the correct item (that which the rendering/sublayout is assigned to).

The following computed index field can be used to index the templates used as datasources against renderings or sublayouts. You may also be interested in indexing child content against an item.

The code will need modification to work in your implementation, but how it works is as follows:
  1. Get all renderings/sublayouts for the item
  2. Filter down to renderings/sublayouts of a desired type (and which have a datasource)
  3. For each datasource, concatenate the desired field to a string and return this string for indexing
The result here is a field in the index which contains the datasource content ready for indexing. It can also be modified to index datasources of multiple types along with multiple fields.

Please note the code would need to be extended to handle rending/sublayout changes based on device along with personalization and A/B multivariate testing.

No comments:

Post a Comment