Thursday, 30 September 2010

MarkLogic: Creating Multiple Range Element Indexes

Here's a quick script to create multiple element range indexes on a MarkLogic database, just set the $db-name variable:


Then pass in a sequence of xs:strings or a single xs:string like so:


For each index, it will report back whether the index was successfully created or not, like so:

Or:

Friday, 24 September 2010

MarkLogic: Listing all Collections in a Database

Looking to list all currently available collections on a given database?

Thursday, 23 September 2010

MarkLogic: Basic Database Cloning Script

A rough note on the process of copying a database from one place to another - attached for reference (in case I need something similar again). This script is untested and adapted from other code I've seen elsewhere:

Tuesday, 21 September 2010

MarkLogic: Estimating the number of documents contained within collections

Two ways of getting quick estimates on documents within collections and the time taken to search through them (using xdmp:elapsed-time):

And using cts:collection-query:

MarkLogic: Search: Compound OR Queries

Useful search tip:

You can pass sequences of words (and wildcarded terms if you have trailing wildcard searches enabled on your database) into an element word query, like so:

Monday, 13 September 2010

MarkLogic: XQuery: Check for the presence of an element

A useful way to combine cts:element-query and cts:and-query to test for the presence of an element.

The and query gets passed an empty sequence () and this will return either true or false depending on whether the element is found.

Thursday, 2 September 2010

MarkLogic: XQuery: Type Validation using xsi:type

Quick note on XQuery based type validation (using xsi:type):

When executed in cq, this should return true.