我正试图将我的一个开发环境从ML8迁移到ML9。我有一个导入脚本,它成功地在ML8版本上运行,但当我尝试在ML9数据库上运行它时出现了错误。ML9版本为9.0.3.1。MLCP版本为9.0.3
我的MLCP选项文件如下:
import
-host
192.168.33.10
-port
8041
-username
admin
-password
admin
-input_file_path
d:maroondatambastest.csv
-mode
local
-input_file_type
delimited_text
-uri_id
ClientId
-output_uri_prefix
/test/records/
-output_uri_suffix
.json
-document_type
json
-transform_module
/ingestion/transform.js
-transform_function
testTransform
-transform_param
test
-content_encoding
windows-1252
-thread_count
1
以下是测试CSV文件中只有2条记录的测试运行的输出:
17/10/30 14:07:33 INFO contentpump.LocalJobRunner: Content type: JSON
17/10/30 14:07:33 INFO contentpump.ContentPump: Job name: local_455168344_1
17/10/30 14:07:33 INFO contentpump.FileAndDirectoryInputFormat: Total input paths to process : 1
17/10/30 14:07:38 WARN contentpump.TransformWriter: Failed document /test/records/31.json
17/10/30 14:07:38 WARN contentpump.TransformWriter: <error:format-string xmlns:error="http://marklogic.com/xdmp/error" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_, expecting $end or SemiColon_</error:format-string>
17/10/30 14:07:38 WARN contentpump.TransformWriter: Failed document /test/records/32.json
17/10/30 14:07:38 WARN contentpump.TransformWriter: <error:format-string xmlns:error="http://marklogic.com/xdmp/error" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected QName_, expecting $end or SemiColon_</error:format-string>
17/10/30 14:07:38 INFO contentpump.LocalJobRunner: completed 100%
17/10/30 14:07:38 INFO contentpump.LocalJobRunner: com.marklogic.mapreduce.MarkLogicCounter:
17/10/30 14:07:38 INFO contentpump.LocalJobRunner: INPUT_RECORDS: 2
17/10/30 14:07:38 INFO contentpump.LocalJobRunner: OUTPUT_RECORDS: 2
17/10/30 14:07:38 INFO contentpump.LocalJobRunner: OUTPUT_RECORDS_COMMITTED: 0
17/10/30 14:07:38 INFO contentpump.LocalJobRunner: OUTPUT_RECORDS_FAILED: 2
17/10/30 14:07:38 INFO contentpump.LocalJobRunner: Total execution time: 5 sec
如果我删除了转换参数,导入工作正常。
我认为这可能是转换模块本身的解析问题,所以我尝试用文档中的以下示例替换它:
// Add a property named "NEWPROP" to any JSON input document.
// Otherwise, input passes through unchanged.
function addProp(content, context)
{
const propVal = (context.transform_param == undefined)
? "UNDEFINED" : context.transform_param;
if (xdmp.nodeKind(content.value) == 'document' &&
content.value.documentFormat == 'JSON') {
// Convert input to mutable object and add new property
const newDoc = content.value.toObject();
newDoc.NEWPROP = propVal;
// Convert result back into a document
content.value = xdmp.unquote(xdmp.quote(newDoc));
}
return content;
};
exports.addProp = addProp;
(当然,我相应地更改了MLCP选项文件中的参数)
即使只有这个测试功能,问题仍然存在。
有什么建议吗?
我发现问题是因为转换模块的扩展名是.js。如果我将其更改为.sjs,MLCP导入将按预期进行。