Skip to content

Instantly share code, notes, and snippets.

@joewiz
Last active July 11, 2017 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joewiz/4885943ac9a196596be6a1e1416e7f58 to your computer and use it in GitHub Desktop.
Save joewiz/4885943ac9a196596be6a1e1416e7f58 to your computer and use it in GitHub Desktop.
Get distinct values, using range indexes in eXist-db
xquery version "3.1";
(: In eXist-db, distinct-values() is not backed by range indexes.
To achieve better performance for this operation, use util:index-keys.
This sample retrieves all distinct indexed values for the @ref attribute. :)
util:index-keys(collection("/db/apps/my-app/data")//@ref, (),
    function($key, $count) {
        $key
    }, -1, "range-index")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment