how to automatically re index child nodes when a parent node is saved
hey out there,
i wanted to check if there's something built into examine/lucene or umbraco that can trigger reindexing of child nodes when a parent is saved?
my structure is that when a child node is saved, i store some info from the parent node in the child document. however, if the info in the parent changes when it's saved, i need to rebuild the documents for the child nodes.
it does work, but due to using the content service to get the node and it's children and then calling 'PublishWithStatus' there's a lot of unnecessary database activity...
hitting the database isn't needed as this is all index work, there's nothing visible on the node in the back office.
i'm wondering if i'm over complicating things and there's something built in to automatically re index child nodes when a parent is saved?
interestingly along the way i found the 'PublishWithChildrenWithStatus()' method in the content service which would seem to be the method called when you right click a node in the back office, select publish and then check the 'Publish xxx and all its subpages'. not really usable for this scenario but useful for future reference.
thank you for the suggestion, this is working a treat now.
how to automatically re index child nodes when a parent node is saved
hey out there,
i wanted to check if there's something built into examine/lucene or umbraco that can trigger reindexing of child nodes when a parent is saved?
my structure is that when a child node is saved, i store some info from the parent node in the child document. however, if the info in the parent changes when it's saved, i need to rebuild the documents for the child nodes.
at the moment, i've gone for this:
it does work, but due to using the content service to get the node and it's children and then calling 'PublishWithStatus' there's a lot of unnecessary database activity...
hitting the database isn't needed as this is all index work, there's nothing visible on the node in the back office.
i'm wondering if i'm over complicating things and there's something built in to automatically re index child nodes when a parent is saved?
cheers,
jake
Jake,
Why not republish the items in the parent on publish event https://our.umbraco.com/Documentation/Reference/Events/ContentService-Events just ensure that the current type that is being published is of type who children you want to republish.
Regards
Ismail
hi ismail,
spot on, just what i was after ;)
a bit of experimenting and i've found that hooking into the saved event does the trick:
interestingly along the way i found the 'PublishWithChildrenWithStatus()' method in the content service which would seem to be the method called when you right click a node in the back office, select publish and then check the 'Publish xxx and all its subpages'. not really usable for this scenario but useful for future reference.
thank you for the suggestion, this is working a treat now.
is working on a reply...