无效的 TDE 模板

纳迪亚

我的 MarkLogic 数据库由文件夹“专利”中的几个示例文档组成:

  • /patents/airless_diving.json
  • /patents/smart_racket.json
  • /patents/tuning_ukulele.json
  • /patents/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('/templates/inventionsTemplate.json',inventionsTemplate);

fn:QName("http://marklogic.com/xdmp/tde","templateURI") = "/templates/inventionsTemplate.json" fn:QName("http://marklogic.com/xdmp/tde","模板”)=文档{对象节点{“模板”:对象节点{“上下文”:文本{“专利”},“目录”:数组节点{...},...}}} 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.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章