Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Script to locate error nodes from solr error report, and do something with them.
* @author Younes Regaieg <>
* @version 1.0
//----- Solr error report to be fetched from solr /solr4/alfresco/query?q=EXCEPTIONMESSAGE:*&wt=json&rows=<number-of-rows-to-fetch>
//----- Swap this dummy object with a real object from the output of the endpoint mentionned above.
var solrErrorsReport = {
//---- The actual process method, proceed with care, and do what ever is necessary to fix the node !
function process(node){
logger.log("Processing node " + node.nodeRef + " with name " +;
// Delete the node -- this actually just archives the node unless aspect Temporary is applied
// To actually delete the node, you need to uncomment the next line !
// node.remove();
//------------ The real magic happens here, you probably should not fiddle with the following part ---------------
var ctx =;
var nodeService = ctx.getBean("nodeService",;
if (solrErrorsReport.response){
if ({
var docs =;
for (var i=0; i<docs.length; i++){
var doc = docs[i];
logger.log("Detected DBID:"+doc.DBID);
var nodeRef = nodeService.getNodeRef(doc.DBID);
if (nodeRef){
var node = search.findNode(nodeRef);
logger.log("It sounds like the node does no longer exist !");
logger.log("no errors detected !");
logger.log("Sounds like a mal-formatted object was provided !");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.