'How to call collector customize module in MARKLOGIC-DHF 5.6.1

I need to call external collector customize module in DHF 5.6.1. How can I do that? When I passed module in source query, it works but in main.sjs, I can only see 'uri' is coming within 'content' object. I can't see 'value' and 'context' within content object . Am I doing right or not? Is there a proper way to achieve it?



Solution 1:[1]

if you wish to see a 'value' and 'context' within the content object, those aren't returned out-of-the-box and should be configured in your main.sjs that is being referenced.

For example, this is one instance of the 'value' and 'context' can be configured and returned with your custom module (obviously it is generating a different use case but the concept should still apply)

function main(content, options) {
  const inputDocument = content.value;
  
  let additionalContent = [];
  let myNodeList = inputDocument.getElementsByTagName("person");
  if(myNodeList && myNodeList.length){
    for(var i = 0; i < myNodeList.length; i++){
      additionalContent.push({
        uri: `/integration/analytics/${i}.json`,
        value: myNodeList[i],
        context: content.context
      })
    }
  }

  return additionalContent;
}

module.exports = {
  main
};

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brian