Examine event not firing to implement GatheringNodeData in 6.1
Hi,
I've hit a snag when debugging some custom Lucene searches on a site.
There are some multi-node tree picker ids which need to be written out as node names and included as a custom Examine field, called 'relationData'. Having installed Examine Inspector I see this field in the index but it's currently not containing any data, so it would appear that the examine event is not firing.
The class I have been using to do this I notice is marked as obsolete, so instead I've updated the code to the following:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Xml.Linq;
using Examine;
using umbraco.BusinessLogic;
using UmbracoExamine;
using umbraco.NodeFactory;
using umbraco.interfaces;
using Umbraco.Core;
namespace Client.Utilities
{
public class ExamineEvents : IApplicationEventHandler
{
public ExamineEvents()
{
ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"].GatheringNodeData += this.IndexLocations_GatheringNodeData;
}
private void IndexLocations_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
{
if (e.IndexType == IndexTypes.Content)
{
var fields = e.Fields;
var combinedFields = new StringBuilder();
foreach (var keyValuePair in fields)
{
string propertyAlias = keyValuePair.Key;
switch (propertyAlias)
{
case "category":
var categories = keyValuePair.Value.Split(',');
foreach (string categoryId in categories)
{
var node = new Node(Convert.ToInt32(categoryId));
combinedFields.AppendLine(node.Name);
};
break;
case "tags":
var tags = keyValuePair.Value.Split(',');
foreach (string tag in tags)
{
combinedFields.AppendLine(tag);
};
break;
}
}
e.Fields.Add("relationData", combinedFields.ToString());
}
}
}
}
...however I now get build errors:
"Client.Utilities.ExamineEvents does not implement interface member umbraco.core.iapplicationeventhandler.onapplicationstarted"
"Client.Utilities.ExamineEvents does not implement interface member umbraco.core.iapplicationeventhandler.onapplicationstarting"
"Client.Utilities.ExamineEvents does not implement interface member umbraco.core.iapplicationeventhandler.onapplicationinitialized"
This is all a bit over my head, so I wondered if anyone could shed any light on how to resolve this?
Many thanks folks.
EDIT:
I've seen a note in the documentation which suggests that some other methods need to be implemented as it's an interface, so I've added:
public void OnApplicationInitialized(UmbracoApplication httpApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarting(UmbracoApplication httpApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarted(UmbracoApplication httpApplication, ApplicationContext applicationContext)
{
}
Because you are implementing an interface - IApplicationEventHandler - you need to implement all methods, so that's why you need to add those 3 methods to your class in order to get the project to build.
Having done that I think if you move this line of code...
Thanks Andy, but it gives the same 3 build errors. Incidentally, there's a blue line on the word 'ExamineEvents' on this line: public class ExamineEvents : IApplicationEventHandler, with the message:
'Client.Utilities.ExamineEvents' does not implement interface member 'Umbraco.Core.IApplicationEventHandler.OnApplicationInitialized(Umbraco.Core.UmbracoApplicationBase, Umbraco.Core.ApplicationContext)'
Doesn't look to me that you can have added those three methods to the class if you are still getting that build error. If you want to post the whole code you have for your ExamineEvents class I can have another look if you like?
I then registered the following: ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"].GatheringNodeData+=this.IndexLocations_GatheringNodeData;
inside the OnApplicationStarted method and kept the rest of the code exactly the same!
Hope this helps you out Mr. OP as your post helped me!
Examine event not firing to implement GatheringNodeData in 6.1
Hi,
I've hit a snag when debugging some custom Lucene searches on a site.
There are some multi-node tree picker ids which need to be written out as node names and included as a custom Examine field, called 'relationData'. Having installed Examine Inspector I see this field in the index but it's currently not containing any data, so it would appear that the examine event is not firing.
The class I have been using to do this I notice is marked as obsolete, so instead I've updated the code to the following:
...however I now get build errors:
This is all a bit over my head, so I wondered if anyone could shed any light on how to resolve this?
Many thanks folks.
EDIT:
I've seen a note in the documentation which suggests that some other methods need to be implemented as it's an interface, so I've added:
... but this doesn't seem to make any difference.
Hi Dan
Because you are implementing an interface - IApplicationEventHandler - you need to implement all methods, so that's why you need to add those 3 methods to your class in order to get the project to build.
Having done that I think if you move this line of code...
... to the method OnApplicationStarted then it should start to fire.
Hope that helps.
Andy
Thanks Andy, but it gives the same 3 build errors. Incidentally, there's a blue line on the word 'ExamineEvents' on this line:
public class ExamineEvents : IApplicationEventHandler
, with the message:Any ideas?
(Incidentally, this is Umbraco 6.1.6.)
Thanks
Doesn't look to me that you can have added those three methods to the class if you are still getting that build error. If you want to post the whole code you have for your ExamineEvents class I can have another look if you like?
Hi,
I had the exact same issues as the OP however, I changed the following:
to
I then registered the following:
ExamineManager.Instance.IndexProviderCollection["ExternalIndexer"].GatheringNodeData+=this.IndexLocations_GatheringNodeData;
inside the OnApplicationStarted method and kept the rest of the code exactly the same!
Hope this helps you out Mr. OP as your post helped me!
Thanks,
Rick
is working on a reply...