Reputation:
Is there any way to find the frequency of an element that does not have a range index ? the
cts:frequency()
that I use does not support any element that is not lexicon
Upvotes: 1
Views: 118
Reputation: 8422
You'll need some type of index in order to get counts. Besides a range index, here's an approach using a word lexicon:
for $word in cts:element-words(xs:QName("city"))
return
$word || " " ||
xdmp:estimate(
cts:search(
fn:doc(),
cts:element-word-query(xs:QName("city"), $word)))
Understand that this approach might not give you the values you're expecting if you have multi-word values. For instance, if you have <city>San Francisco</city> and <city>San Diego</city>, you'll get these counts:
For getting accurate, value-based counts, a range index is your best bet.
Upvotes: 5