问题描述
当我通过MLCP提取文档时,我正在尝试实现信封模式
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;
我的MLCP命令就是这样
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错误:
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
我不知道为什么它无法读取我的转换模块中的uri
.感谢您的帮助
I don't know why it cant able to read the uri
in my transform module.Any help is appreciated
谢谢
推荐答案
MLCP期望transform函数返回更新的content
参数.请尝试以下操作:
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;
使用-output_collections
参数提供目标集合名称.您也可以使用-output_uri_prefix
或-output_uri_replace
参数为uri加上/transformed/
前缀.
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
有关MLCP转换的文档可以在这里找到:
Documentation about MLCP transforms can be found here:
http://docs.marklogic.com/guide/mlcp/import#id_82518
HTH!
这篇关于在MLCP提取到MarkLogic的过程中使用转换模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!