Creating Computed Index field in Sitecore 8

Why do we need Computed Indexed Field?

Computed fields are a great way of storing calculated information while Sitecore indexes your items as opposed to using more resource to calculate it on the fly for use in your sublayouts/layouts.


  • Create a class which implements AbstractComputedIndexField
  • Use the method Sitecore.ContentSearch.ComputedFields namespace, then override the ComputeFieldValue method.
  • Create a config-include file which adds the computed index field to the index configuration.Here I will using the same example used in “Uli” Blogs, but I have made the changes code and config file so that it can work in Sitecore 8.
  • Author TemplateComputedField1
  • Publication Template



    Below code will create the IndexField name “AuthorPublications”. And this field will contain all the Publication ID related to the Author.


    public class AuthorPublications : AbstractComputedIndexField
    public override object ComputeFieldValue(IIndexable indexable)
    Item item = indexable as SitecoreIndexableItem;
    if (item == null)
    return null;
    if (item.TemplateName != “Author”)
    return null;
    return GetPublicationIDs(item);

    private IEnumerable<Guid> GetPublicationIDs(Item authorItem)
    return (from link in Globals.LinkDatabase.GetItemReferrers(authorItem, false)
    let sourceItem = link.GetSourceItem()
    where sourceItem != null
    where sourceItem.TemplateName == “Publication”
    select sourceItem.ID.Guid).ToArray();

    public string FieldName
    public string ReturnType

    Create a new Config file “ComputedIndexFields.config” and add the namespace & DLL name in the field

    <?xml version=”1.0″ encoding=”utf-8″ ?>

    <configuration xmlns:patch=””&gt;
    <defaultLuceneIndexConfiguration type=”Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider”>
    <fields hint=”raw:AddComputedIndexField”>
    <field fieldName=”AuthorPublications” storageType=”YES” indexType=”TOKENIZED”>Namespace.AuthorPublications, DLL Name </field>

    After adding the file in App_config/Include folder, Kindly check in Sitecore\admin\Showconfig.aspx

    Debugging using Visual Studio.

    1)      Open the Visual Studio -> Attached the debugger.

    2)      In Desktop-> Control Panel-> Indexing Manager-> Rebuild the Search Index.

    Also in Luke you can find the field







Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.