Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Heather Floyd 606 posts 1007 karma points MVP 6x c-trib
    Jul 24, 2015 @ 17:15
    Heather Floyd
    0

    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!

  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jul 24, 2015 @ 17:34
  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Jul 24, 2015 @ 17:41
  • Heather Floyd 606 posts 1007 karma points MVP 6x c-trib
    Jul 28, 2015 @ 15:44
    Heather Floyd
    1

    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:

    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);
    
  • Rusty Swayne 1655 posts 4993 karma points c-trib
    Jul 28, 2015 @ 15:48
    Rusty Swayne
    0

    Ah sweet. I did not know about that extension method. I'll have to look that up.

Please Sign in or register to post replies

Write your reply to:

Draft