Skip to content

Instantly share code, notes, and snippets.

@jmakeig
Created January 8, 2014 22:20
Show Gist options
  • Save jmakeig/8325504 to your computer and use it in GitHub Desktop.
Save jmakeig/8325504 to your computer and use it in GitHub Desktop.
From a random sample of all documents in a MarkLogic database, returns a list of distinct paths to the leaf element whose local name matches a regular expression. You wouldn’t want to do this on the whole database because the XPath is very expensive.
xquery version "1.0-ml";
distinct-values(
cts:search(collection(), cts:and-query(()), ("unfiltered","score-random"))[1 to 100]
//*[matches(local-name(.), "Address$")]/xdmp:path(.)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment