Shi*_*are 3 marklogic marklogic-9
我的要求是,仅当路径范围索引值以某个单词开头或结尾时,我才想返回文档 URI。
根据 MarkLogic 文档,我只能使用 ">、<、<=、>=、=、!=" 来比较路径范围索引值,但在我的要求中,我想使用 fn:starts-with() 或 fn:ends-和()。
有什么办法可以满足这个要求吗?
您可以使用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))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
88 次 |
| 最近记录: |