Reputation: 59
How to return all values starting with Ar* when we search for a facet
xquery version "1.0-ml";
import module namespace search = "http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<values name="entity">
<range type="xs:string">
<element ns="http://www.com/mynamespace" name="country" />
</range>
</values>
<return-metrics>false</return-metrics>
</options>
return search:values("entity", $options)
Upvotes: 1
Views: 245
Reputation: 20414
I don't think you can do this with search:values
. It does take a start
parameter, for which you could specify Ar
, but that would only provide a lower-bound, not an upper bound. Proving a range query for upper and lower bound won't help either if you have concurrent values in your document fragments.
In case you can use cts functions directly, I'd say use cts:value-match
. That can work with your wildcards directly:
cts:value-match(cts:element-reference(fn:QName("http://www.com/mynamespace", "country"), "Ar*")
HTH!
Upvotes: 2