1

我是 MarkLogic 的新手。

我有 XML 文档

<?xml  version="1.0" encoding="UTF-8"?>
<books xmlns="http://www.marklogic.com/ns/gs-books">
<book bookid="2">
<title>A Quick Path to an Application</title>
<author>
<last>Smith</last>
<first>James</first>
</author>
<publisher>Scribblers Press</publisher>
<isbn>1494-3930392-4</isbn>
<abstract>
          This book describes in detail the power of how 
          to use Java to build powerful web applications 
          that are built on the MarkLogic Server platform.
      </abstract>
</book>
</books>

我该如何使用cts:element-values它?

这是我的尝试: cts:element-values(xs:QName("test"),"test")

它给了我这个错误:

[1.0-ml] XDMP-ELEMRIDXNOTFOUND: cts:element-values(fn:QName("","t"), "t") -- t collat​​ion=http://marklogic.com/collat​​ion 没有元素范围索引/坐标系=wgs84 [marklogic]

4

1 回答 1

4

为了能够使用cts:element-values(),元素需要有一个相应的范围索引才能使用。

从指定的元素值词典返回值。值词典是使用范围索引实现的;因此,此函数需要函数中指定的每个元素的元素范围索引。如果没有为每个指定元素配置范围索引,则会引发异常。

因此,为了能够运行:cts:element-values(xs:QName("test"),"test")

您首先需要为 " test" 元素创建一个字符串范围索引(并确保启用了重新索引器,并允许它使用该元素完成对文档的重新索引,以便构建词典)。

您可以在Admin UI中以编程方式配置 element-range-index admin:database-add-range-element-index(),如果您有ml-gradle项目,则可以将它们添加到数据库配置中。

于 2021-10-04T20:54:06.463 回答