Suppose I have a lot of documents with a State element.
I would like a list of all states and the corresponding number of documents in
that state. I can write a FLOWR statement to do this but I believe there is a
direct query to do this efficiently. Any suggestions ?
This appears to run very quickly ... any suggestions for improvement ?
for $state in cts:element-values( xs:QName(State) )
return ($state , cts:frequency($state) )
-
David Lee
Lead Engineer
MarkLogic Corporation
You could leverage search:search to get it back as if it were just another
facet, but you’d be typing a lot more, just for the facet definition, and
under the hood, any strategy would end up doing exactly what you are doing
already I guess. Your approach is essentially the way to go.
Kind