Skip to content

Instantly share code, notes, and snippets.

@soen
Last active August 22, 2016 17:54
Show Gist options
  • Save soen/a387251b70ae3970201845729e0889ba to your computer and use it in GitHub Desktop.
Save soen/a387251b70ae3970201845729e0889ba to your computer and use it in GitHub Desktop.
public class MyComputedIndexField : IComputedIndexField
{
public object ComputeFieldValue(IIndexable indexable)
{
// Check that we have something to index
if (indexable == null)
return null;
// Check that it is a Sitecore indexable item
var indexableItem = indexable as SitecoreIndexableItem;
if (indexableItem == null)
return null;
// We're in business, let's grab the Sitecore item being indexed, and do stuff!
Item sitecoreItem = indexableItem.Item;
// Sneaky computations goes here...
// Finally we return the value, that we need to store in the search index
return "The value stored in the index";
}
public string FieldName { get; set; }
public string ReturnType { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment