我的MarkLogic数据库由“专利”文件夹中的几个示例文档组成:
每一份文件都是这样的:
{
"patent": {
"title": "Airless SCUBA diving",
"inventor": "Greg",
"description": "Diving pill that provides airless SCUBA diving for up to 1 hour"
}
}我正在尝试创建一个模板:
const tde = require ('/MarkLogic/tde');
const inventionsTemplate = xdmp.toJSON(
{
'template':{
'context':'patent',
'directories':["patents", "another_patents"],
'rows':[
{
'viewName':'inventions',
'columns':[
{
'name':'title',
'scalarType':'string',
'val':'../title',
'nullable':true
},
{
'name':'inventor',
'scalarType':'string',
'val':'../inventor',
'nullable':true
},
{
'name':'description',
'scalarType':'string',
'val':'../description',
'nullable':true
}
]
}]
}
}
);
tde.templateInsert('/templates/inventionsTemplate.json', inventionsTemplate);但是得到了一个错误:
(err:err 0000) tde.templateInsert('/templates/inventionsTemplate.json',inventionsTemplate);-无效TDE模板: TDE-INVALIDTEMPLATENODE:无效提取模板节点: fn:doc("")/template/array-node("rows")/object-node()
第75行第6列的堆栈跟踪:在tde.templateInsert('/templates/inventionsTemplate.json',inventionsTemplate中);
fn:QName("http://marklogic.com/xdmp/tde","templateURI") =“/http://marklogic.com/xdmp/tde","templateURI"/inventionsTemplate.json”fn:QName(“http://marklogic.com/xdmp/tde","template"”=“http://marklogic.com/xdmp/tde","templateURI"”目录“):数组-节点{.},} fn:QName("http://marklogic.com/xdmp/tde","permissions") = () fn:QName("http://marklogic.com/xdmp/tde","collections") = () fn:QName(“http://marklogic.com/xdmp/tde","testvalid"”)=map(http://www.w3.org/2001/XMLSchema“xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance”./>)fn:QName(“http://marklogic.com/xdmp/tde","permarray"”)= json:array() fn:QName(“http://marklogic.com/xdmp/tde","colsarray"”)=json:xmlns:xsi=()
在我的例子中,创建MarkLogic模板驱动提取的正确语法是什么?插入TDE之前,我是否遗漏了一些准备步骤?
发布于 2022-06-02 12:11:32
您的划缺少一个schemaName属性。
如果将它添加到rows数组中的对象中,它将验证和插入。
'rows':[
{
'schemaName':'patents',
'viewName':'inventions',
'columns':[文档可能会得到改进,以指示哪些属性(如schemaName和viewName )是必需的,哪些属性是可选的,例如view-layout。
https://stackoverflow.com/questions/72473991
复制相似问题