Storing a custom field in the Examine index on page save event
Hi all,
I have recently upgraded to Umbraco 7.2.8 from 7.2.4 and it would seem that in this version everything has changed when it comes to writing custom fields to the Examine index in Umbraco.
Previously if I wanted to write a custom field to the Examine index I would do the following:
I have now re-engineered this to the following based upon this article however I now find that nothing is being saved to my custom index at all.
using System;
using System.Text;
using System.Linq;
using System.Xml.Linq;
using System.Collections.Generic;
using Examine;
using umbraco.BusinessLogic;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Web.WebApi;
using Umbraco.Web;
using UmbracoExamine;
namespace Lost_World_Adventures.App_Code.Examine_Extensions
{
public class AppEvents : IApplicationEventHandler
{
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
var helper = new UmbracoHelper(UmbracoContext.Current);
ExamineManager.Instance.IndexProviderCollection["AxumIndexer"].GatheringNodeData
+= (sender, e) => ExamineEvents.GatheringContentData(sender, e, helper);
}
public static void GatheringContentData(object sender, IndexingNodeDataEventArgs e, UmbracoHelper helper)
{
}
}
public static class ExamineEvents
{
public static void GatheringContentData(object sender, IndexingNodeDataEventArgs e, UmbracoHelper helper)
{
var content = helper.TypedContent(e.NodeId);
var homepage = content.Ancestor("homepage");
e.Fields.Add("siteNode", homepage.Id.ToString());
}
}
}
Storing a custom field in the Examine index on page save event
Hi all,
I have recently upgraded to Umbraco 7.2.8 from 7.2.4 and it would seem that in this version everything has changed when it comes to writing custom fields to the Examine index in Umbraco.
Previously if I wanted to write a custom field to the Examine index I would do the following:
However, this no longer works and I cannot find any proper documentation on Our regarding how this should now be done.
Does anyone know what I need to do so that this works with the latest version of Umbraco?
Any help would be greatly appreciated.
I have now re-engineered this to the following based upon this article however I now find that nothing is being saved to my custom index at all.
http://staheri.com/my-blog/2015/march/custom-examine-indexing-using-umbraco-cache/
My final solution was this:
is working on a reply...