Using Transform Module during MLCP Ingestion to MarkLogic

左心房为你撑大大i 提交于 2020-01-30 03:06:37

问题


I am trying to implement envelope pattern when i am ingesting documents through MLCP

My transform Module is like this :

function envelope(content, context)
{
  var transformed ={};
  transformed.Metadata = { "Created" : "Time"};
  transformed.Source = content.value;
  content.uri = fn.concat("/transformed/",content.uri);
  content.value = transformed;
};
exports.transform = envelope;

My MLCP Command is like this

    mlcp.bat import -host localhost -port 8000 -username admin -
password admin -mode local -input_file_path D:\Marklogic\abcd.csv -input_file_ty
pe delimited_text -document_type json -transform_module /example/
mlcp-transform.sjs -transform_function transform -output_collections transformed -ge
nerate_uri true

MLCP Error :

    18/01/31 09:00:27 WARN contentpump.TransformWriter: Failed document /D:/Marklogi
c/test.pcr-0-9
18/01/31 09:00:27 WARN contentpump.TransformWriter: TypeError: Cannot read prope
rty 'uri' of undefined
18/01/31 09:00:27 WARN contentpump.TransformWriter: TypeError: Cannot read prope
rty 'uri' of undefined

I don't know why it cant able to read the uri in my transform module. Any help is appreciated

Thanks


回答1:


MLCP expects the transform function to return an the updated content argument. Try the following:

function envelope(content, context)
{
  var transformed ={};
  transformed.Metadata = { "Created" : "Time"};
  transformed.Source = content.value;
  content.uri = fn.concat("/transformed/",content.uri);
  content.value = transformed;
  return content;
};
exports.transform = envelope;

Provide target collection names with the -output_collections parameter. You can also prefix uri with /transformed/ using the -output_uri_prefix, or the -output_uri_replace parameter.

You can find documentation about command-line options here:

http://docs.marklogic.com/guide/mlcp/import#id_23879

Documentation about MLCP transforms can be found here:

http://docs.marklogic.com/guide/mlcp/import#id_82518

HTH!



来源:https://stackoverflow.com/questions/48526818/using-transform-module-during-mlcp-ingestion-to-marklogic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!