How to use 'ExamineManager.Instance.ReIndexNode()' with custom data?
Hi, I've got a question for those of you with some Examine acumen...
I've got a custom (non umbraco) Indexer set up and working properly by looping through my custom data and creating a "SimpleDataSet" for each item. Now I am adding functionality to update the index when operations happen on the custom objects.
I have successfully set up a "Remove from Index" function to run on object delete by looking up the index nodeId for the object, and passing it to 'ExamineManager.Instance.DeleteFromIndex(...)'
Now I'd like to add operations to run on object create and update which would add just the current object to the index. I was looking at 'ExamineManager.Instance.ReIndexNode()' which expects an "XElement" as the representation of the index data, but I am unclear what format that needs to be in, or how to convert a SimpleDataSet into an XElement.
Is it possible to only index a single object? I'd rather not have to run 'ExamineManager.Instance.IndexAll()' every time something is added or changed... But perhaps that isn't possible?
If you have added custom data to an Umbraco Index, how did you handle updates?
So, I ended up going with the solution in Ismail's Blog post - I hadn't realized that a SimpleDataSet had a "ToExamineXml" method. Since I already have a function which builds an SDS for my custom object, that was the simplest solution.
I appreciated reading your code, Rusty, because I now have a reference if I ever need to have more control over the XML for the Examine node.
So, for posterity, here is a simplified snippet of what I ended up using:
var examineId = GetMaxId(myIndexTypeName) + 1;
var sds = [...function that is passed my custom object and returns an SDS...];
var examineNode = sds.RowData.ToExamineXml(examineId, myIndexTypeName);
ExamineManager.Instance.ReIndexNode(examineNode, myIndexTypeName, myCustomIndexer);
How to use 'ExamineManager.Instance.ReIndexNode()' with custom data?
Hi, I've got a question for those of you with some Examine acumen...
I've got a custom (non umbraco) Indexer set up and working properly by looping through my custom data and creating a "SimpleDataSet" for each item. Now I am adding functionality to update the index when operations happen on the custom objects.
I have successfully set up a "Remove from Index" function to run on object delete by looking up the index nodeId for the object, and passing it to 'ExamineManager.Instance.DeleteFromIndex(...)'
Now I'd like to add operations to run on object create and update which would add just the current object to the index. I was looking at 'ExamineManager.Instance.ReIndexNode()' which expects an "XElement" as the representation of the index data, but I am unclear what format that needs to be in, or how to convert a SimpleDataSet into an XElement.
Is it possible to only index a single object? I'd rather not have to run 'ExamineManager.Instance.IndexAll()' every time something is added or changed... But perhaps that isn't possible?
If you have added custom data to an Umbraco Index, how did you handle updates?
Thanks!
Checkout https://github.com/Merchello/Merchello/blob/merchello-dev/src/Merchello.Core/Models/InvoiceExtensions.cs around line 804.
I think this post explains how to update/create entries:
http://thecogworks.co.uk/blog/posts/2013/february/examiness-hints-and-tips-from-the-trenches-part-8-custom-indexing/
Thanks, Rusty & Morten!
So, I ended up going with the solution in Ismail's Blog post - I hadn't realized that a SimpleDataSet had a "ToExamineXml" method. Since I already have a function which builds an SDS for my custom object, that was the simplest solution.
I appreciated reading your code, Rusty, because I now have a reference if I ever need to have more control over the XML for the Examine node.
So, for posterity, here is a simplified snippet of what I ended up using:
Ah sweet. I did not know about that extension method. I'll have to look that up.
is working on a reply...