【问题标题】:Marklogic fail to create element range indexMarklogic 无法创建元素范围索引
【发布时间】:2018-12-14 18:44:31
【问题描述】:

创建元素范围索引失败。 Error Invalid coercion range-element-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 创建元素范围索引但未能创建它。错误显示无效强制。我无法弄清楚是什么原因造成的。

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)

【问题讨论】:

    标签: marklogic


    【解决方案1】:

    管理库围绕 $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!

    【讨论】:

    • 在创建元素范围索引索引时关闭Qconsole浏览器会怎样? Marklogic 后端是否继续构建元素范围索引,直到完成索引或停止进程。我担心午夜后笔记本电脑会自动关机。
    • 保存配置更改很快。数据库的重新索引很慢,但发生在后台..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多