Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ItemYear : AbstractComputedIndexField
- {
- public override object ComputeFieldValue(IIndexable indexable)
- {
- Item item = indexable as SitecoreIndexableItem;
- DateTime date = EXTRACT DATE FROM THE ITEM;
- return date.Year;
- }
- }
- <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
- <sitecore>
- <contentSearch>
- <indexConfigurations>
- <defaultLuceneIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider">
- <documentOptions type="Sitecore.ContentSearch.LuceneProvider.LuceneDocumentBuilderOptions, Sitecore.ContentSearch.LuceneProvider">
- <fields hint="raw:AddComputedIndexField">
- <field fieldName="year" returnType="int">NAMESPACE.ItemYear , ASSEMBLY_NAME</field>
- </fields>
- </documentOptions>
- </defaultLuceneIndexConfiguration>
- </indexConfigurations>
- </contentSearch>
- </sitecore>
- </configuration>
Add Comment
Please, Sign In to add comment