In my documents there are two elements(<a> and <b>) on which range indexes(of the same type) exist. I want all those documents in which the values of <a> and <b> are same. I understand that using cts:element-value-co-occurrences()
I can fetch the pair of values of <a> and <b> from each fragment and compare the values. But how do I refer back to the fragment where a match is found? Or is there a simpler way to do this? All I want is the range indexes to get utilized.
The co-occurences functions return a list of all existing (within-fragment) value combinations of those two elements. If you simply look for all documents in which the value of element a is equal to the value of element b, you could do something like:
for $v in cts:element-values(xs:QName("a"))
return
cts:search(
collection(),
cts:and-query((
cts:element-value-query(xs:Qname("a"), $v),
cts:element-value-query(xs:Qname("b"), $v)
))
)
Or you could use cts:uris
instead of cts:search
to find the database uris of those docs..
ADDED:
What @mblakele in the comment below means is this:
let $query :=
cts:or-query(
for $v in cts:element-values(xs:QName("a"))
return
cts:and-query((
cts:element-value-query(xs:Qname("a"), $v),
cts:element-value-query(xs:Qname("b"), $v)
))
)
return
cts:search(
collection(),
$query
)
That saves you from doing cts:search for each value separately, and is likely to perform quicker..
HTH!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With