无效TDE模板



我的MarkLogic数据库由文件夹"patents"中的几个示例文档组成:

  • /专利/airless_diving.json
  • /专利/smart_racket.json
  • /专利/tuning_ukulele.json
  • /专利/waterski_drone.json

每个文档看起来像这样:

{
"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);

但是出现错误:

[javascript] TDE-INVALIDTEMPLATE: (err:FOER0000) tde.templateInsert('/templates/inventionsTemplate. ')json, inventionsTemplate);——无效的TDE模板:TDE- invalidtemplatenode:无效的提取模板节点:fn:doc(")/template/array-node("rows")/object-node()

堆栈跟踪在第75行第6列:在tde.templateInsert('/模板/inventionsTemplate。json, inventionsTemplate);

fn:QName("http://marklogic.com/xdmp/tde","templateURI") = "/templates/inventonstemplate .json"fn:QName("http://marklogic.com/xdmp/tde","template") = document{object-node{"template":object-node{"context":text{"patent"; directores& quot;:array-node{…},…}}}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:map(" map:map xmlns:xs="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:array()

在我的情况下,创建MarkLogic模板驱动提取的正确语法是什么?在插入TDE之前,我是否遗漏了一些准备步骤?

您的行缺少一个schemaName属性。

如果你将它添加到rows数组中的对象,它将验证并插入。

'rows':[
{
'schemaName':'patents',
'viewName':'inventions',
'columns':[

文档可能会得到改进,以指出哪些属性是必需的,例如schemaNameviewName,哪些是可选的,例如view-layout

最新更新