Sunday, March 16, 2008

Basic Information on MarkLogic Collections

I wanted to get some quick information about all of my collections, starting with a list of names and how many documents were in each. This isn't rocket science, but I'll add to this post as the query expands.

(: Set "collection lexicon" to true in the index definition. :)
let $collections := cts:collections() return
<root count="{ fn:count($collections) }">
{
for $collection in $collections
return
<collection>
<name> { $collection } </name>
<size> { fn:count(fn:collection($collection)) } </size>
</collection>
}
</root>

1 comment:

Unknown said...

I tried this and it failed because the collection lexicon was not enabled. You should note that you need to enable the collections lexicon.