GatheringNodeData has been removed/consolidated in the version of Examine shipped with V8
The event you want to handle instead is 'TransformingIndexValues' event
you can see this in the source code:
/// <summary>
/// Raised before the item is indexed allowing developers to customize the data that get's stored in the index
/// </summary>
public event EventHandler<IndexingItemEventArgs> TransformingIndexValues;
/// <summary>
/// Raises the <see cref="E:TransformingIndexValues"/> event.
/// </summary>
/// <param name="e">The <see cref="IndexingItemEventArgs"/> instance containing the event data.</param>
protected virtual void OnTransformingIndexValues(IndexingItemEventArgs e)
{
TransformingIndexValues?.Invoke(this, e);
}
Now I only need to know how to get the instance of the IndexProvider (for ExternalIndex) to attach the event... Since there isn't an IndexProviderCollection in ExamineManager.Instance, can you tell me where I can find it nowadays?
It's a bit of a guess, but essentially everything is injected via DI in Umbraco V8...
So to get a reference to the Examine Manager you need to add it to the constructor for your Component, and it will be magically injected in, the Examine Manager has a list of indexes, if you pull the one you want to handle the event for and cast it to a BaseIndexProvider then that should expose the TransformingIndexValues event...
but I'm only guessing from the source and intellisense!
namespace Umbraco8.Components
{
[RuntimeLevel(MinLevel = RuntimeLevel.Run)]
public class RegisterExamineEventComposer : IUserComposer
{
public void Compose(Composition composition)
{
// Append our component to the collection of Components
// It will be the last one to be run
composition.Components().Append<RegisterExamineEventsComponent>();
}
}
public class RegisterExamineEventsComponent : IComponent
{
private readonly IExamineManager _examineManager;
public RegisterExamineEventsComponent(IExamineManager examineManager)
{
_examineManager = examineManager;
}
public void Initialize()
{
var externalIndex = _examineManager.Indexes.Where(f => f.Name == "ExternalIndex");
((BaseIndexProvider)externalIndex).TransformingIndexValues += TreeNodesRenderingComponent_TransformingIndexValues;
}
private void UmbracoExamineIndex_TransformingIndexValues(IndexingItemEventArgs e)
{
// do stuff here with the index values like gathering nodedata did
}
}
It's a mess... As we can not change how your field will be indexed (Analyzed, not, stored, not stored ?) ... So now I index tags... and there is nothing I can do with it... I don't want half tags to be found !
v8 - ExamineManager - GatheringNodeData how to, with latest Examine
We used to do this (to add some extra data to Examine index for certain nodes)
Now this doesn't seem to work anymore. IndexProviderCollection isn't available.. Is there any other way to init this event ?
Hi Remko
GatheringNodeData has been removed/consolidated in the version of Examine shipped with V8
The event you want to handle instead is 'TransformingIndexValues' event
you can see this in the source code:
which is available here:
https://github.com/Shazwazza/Examine/blob/864168c7f019908242dd56197e075edea5ee77cf/src/Examine/Providers/BaseIndexProvider.cs
Not seen any examples yet, but hopefully that's a good steer.
regards
Marc
Ok, that makes sense, thank you.
Now I only need to know how to get the instance of the IndexProvider (for ExternalIndex) to attach the event... Since there isn't an IndexProviderCollection in ExamineManager.Instance, can you tell me where I can find it nowadays?
Hi Remko
It's a bit of a guess, but essentially everything is injected via DI in Umbraco V8...
So to get a reference to the Examine Manager you need to add it to the constructor for your Component, and it will be magically injected in, the Examine Manager has a list of indexes, if you pull the one you want to handle the event for and cast it to a BaseIndexProvider then that should expose the TransformingIndexValues event...
but I'm only guessing from the source and intellisense!
regards
Marc
Great! Still don't really understand how objects are magically injected in IComponents, but it seems to work :-)
Thank you.
Hi Remko
it is dark magic I think...
regards
Marc
It's a mess... As we can not change how your field will be indexed (Analyzed, not, stored, not stored ?) ... So now I index tags... and there is nothing I can do with it... I don't want half tags to be found !
Any updates on how to achieve this now? Looking at migrating a V7 site over that uses GatheringNodeData and came across this post.
Appears Nik has already answered this one so adding here for completeness :)
https://our.umbraco.com/forum/extending-umbraco-and-using-the-api/98612-examine-events
is working on a reply...