我的要求是,仅当路径范围索引值以某个单词开头或结尾时才想返回文档URI。
根据Per MarkLogic文档,我只能使用“>,<,<=,> =,=,!=”来比较路径范围索引值,但在我的要求下,我想使用fn:starts-with()或fn:ends- with()。
有什么办法可以满足这个要求?
您可以使用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))