Marklogic 无法创建元素范围索引

Marklogic fail to create element range index

无法创建元素范围索引。 错误强制转换范围元素索引 xmlns="http://marklogic.com/xdmp/database">...... 作为元素(配置)

我在数据库中有超过 1 亿个文档需要索引 "tr:ModifiedDate"。

 <?xml  version="1.0" encoding="UTF-8"?>
 <mdra:Record Type="TR" xmlns:mdra="http://dvtech.com/mdra/record">
 <tr:Raw xmlns:tr="http://dvtech.com/mdra/record/tr">
        <tr:History>
           <tr:ModifiedDate>2009-03-18T09:07:23.000-04:00</tr:ModifiedDate>
           <tr:DrolsNdxDate>2002-07-05T18:33:26.000-04:00</tr:DrolsNdxDate>
        </tr:History>            

        <tr:TrlType>
           <tr:Code>0</tr:Code>
       </tr:TrlType>
</tr:Raw>  
</mdr:Record>

我在 tr:ModifiedDate 上创建了 element-range-index 但创建失败。错误显示 Invalid coercion。我不知道是什么原因造成的。

xquery version "1.0-ml";

import module namespace admin = "http://marklogic.com/xdmp/admin"
      at "/MarkLogic/admin.xqy";

let $config := admin:get-configuration()
let $dbid := xdmp:database("IAD")

let $rangespec := admin:database-range-element-index("dateTime",                            
          "http://dvtech.com/mdra/record/tr",
          "ModifiedDate",       
          "http://marklogic.com/collation/",
          fn:false() )

 return
 admin:save-configuration($rangespec)

管理库围绕着 $config。您需要更新该配置,然后保存配置,而不仅仅是一个索引定义。您将使用 admin:database-add-range-element-index 来执行此操作。正确的做法是这样的:

xquery version "1.0-ml";

import module namespace admin = "http://marklogic.com/xdmp/admin"
      at "/MarkLogic/admin.xqy";

let $config := admin:get-configuration()
let $dbid := xdmp:database("IAD")

let $rangespec := admin:database-range-element-index(
  "dateTime",                            
  "http://dvtech.com/mdra/record/tr",
  "ModifiedDate",       
  "http://marklogic.com/collation/",
  fn:false()
)

let $config := admin:database-add-range-element-index($config, $dbid, $rangespec)
return
  admin:save-configuration($config)

您可以通过一次调用该函数来添加多个范围索引。

我还想提一下,有一些部署工具可以帮助将范围索引部署到 MarkLogic 中。一个很好的例子是 ml-gradle.

HTH!