3

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?

DevNinja
  • 1,459
  • 7
  • 10

1 Answers1

5

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))
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147