When I publish a page my ExamineEvents are fired although when I manually rebuild the index they are not, any idea on how I can achieve the same functionality if the index was rebuilt ?
public class ExamineEvents : IApplicationEventHandler
{
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
BaseIndexProvider externalIndexer = ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"];
externalIndexer.GatheringNodeData += OnGatheringNodeData;
WebApiConfig.Register(GlobalConfiguration.Configuration);
}
private void OnGatheringNodeData(object sender, IndexingNodeDataEventArgs e)
{
// logging stuff
//LogHelper.Info<IndexExtender>("Extending index node: IndexType={0}, Indexer={1}, NodeId={2}", () => e.IndexType, () => _indexer.Name, () => e.NodeId);
try
{
// retrieve json array stored in the examine index field, which is configurated to index content property of 'uTaxonomy'
var locationsJson = e.Fields["category"];
// deserialize raw json array to the list of strings
var locationIds = JsonConvert.DeserializeObject<List<string>>(locationsJson);
var locationNames = new List<string>();
// iterate over the identifiers to retrieve taxonomy names
foreach (var locId in locationIds)
{
// "Locations Taxonomy" - Umbraco uTaxonomy data type
Taxonomy location = TaxonomyService.GetTaxonomyById("Taxonomy", locId);
locationNames.Add(location.ToString());
}
// produce a string containing location names separated by space to make it available for searching and put the string into the new examine field
e.Fields["category_searcheable"] = string.Join(" ", locationNames);
// for now its possible to search by location name against "locations_searcheable" examine field
}
catch (Exception ex)
{
// logging stuff
//LogHelper.Error<IndexExtender>(string.Format("Extending index node failed: IndexType={0}, Indexer={1}, NodeId={2}", e.IndexType, _indexer.Name, e.NodeId), ex);
}
}
Firing Examine Events when Index Rebuilt
Hello All
When I publish a page my ExamineEvents are fired although when I manually rebuild the index they are not, any idea on how I can achieve the same functionality if the index was rebuilt ?
is working on a reply...