My Requirement is, I want to return document URI only if path range index value is starts-with or ends-with some word.
As Per MarkLogic documentation I can only use ">, <, <=, >=, =, !=" to compare path range index value but in my requirement I want to use fn:starts-with() or fn:ends-with().
Is there any way to satisfy this requirement?
You could use cts:value-match()
with leading and trailing wildcards to find all of the values that start-with and end-with the value.
Then use cts:path-range-query()
with those values in a call to 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))