、=、=、!= 来比较路径范围索引值,但在我的要求中,我想使用 fn:s-6ren">
gpt4 book ai didi

marklogic - 如何使用 fn :starts-with() and fn:ends-with() with cts:uris()

转载 作者:行者123 更新时间:2023-12-02 22:22:44 29 4
gpt4 key购买 nike

我的要求是,仅当路径范围索引值以某个单词开头或结尾时,我才想返回文档 URI。

根据 MarkLogic 文档,我只能使用 ">、<、<=、>=、=、!= 来比较路径范围索引值,但在我的要求中,我想使用 fn:starts-with() 或 fn :以()结尾。

有什么办法可以满足这个要求吗?

最佳答案

您可以使用cts:value-match()使用前导和尾随通配符查找以该值开头和结尾的所有值。

然后使用 cts:path-range-query()在调用 cts:uris() 时使用这些值

let $path := "/doc/foo";
let $word := "bar";
(: find the values that start with and end with the $word :)
let $values-starts-and-ends-with := (
cts:value-match(cts:path-reference($path), $word||"*"),
cts:value-match(cts:path-reference($path), "*"||$word)
)
(: use those values to find the URIs of docs with those values at that path :)
cts:uris("", (), cts:path-range-query($path, "=", $values-starts-and-ends-with))

关于marklogic - 如何使用 fn :starts-with() and fn:ends-with() with cts:uris(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60391158/

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