gpt4 book ai didi

marklogic - cts :values function not returning all the values for path reference

转载 作者:行者123 更新时间:2023-12-03 21:56:16 24 4
gpt4 key购买 nike

假设我在 MarkLogic 中有三个文档,如下所示,

 <employee>
<name>a</name>
<age>10</age>
</employee>

<employee>
<name>b</name>
<age>10</age>
</employee>

<employee>
<name>c</name>
<age>10</age>
</employee>

文件uris - /employee/a,/employee/b,/employee/c 分别。
我为 "/employee/age" 创建了路径范围索引如 int标量类型。

我的要求是 - 获取路径范围索引的所有值的总和 "/employee/age" .

我试过 - sum(cts:values(cts:path-reference("/employee/age")))但是 它返回 10 作为输出总和 这里 我期待 30 作为输出总和 .

上述问题的解决方案是什么?

最佳答案

cts:values()函数返回存在的不同值的列表。它返回了一个 10 值,所以你的总和是 10。

试试 cts:sum-aggregate()这适用于此用例并考虑了频率。文档可以在 http://docs.marklogic.com/cts:sum-aggregate 找到.

关于marklogic - cts :values function not returning all the values for path reference,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61672439/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com