Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created December 30, 2015 09:13
Show Gist options
  • Select an option

  • Save ableasdale/90e64e6a234e06f60391 to your computer and use it in GitHub Desktop.

Select an option

Save ableasdale/90e64e6a234e06f60391 to your computer and use it in GitHub Desktop.
Get unique term keys from xdmp:plan
xquery version "1.0-ml";
declare namespace qry="http://marklogic.com/cts/query";
declare variable $QUERY as cts:query := cts:word-query( ("one", "two") );
declare function local:get-keys($query as cts:query) as xs:unsignedLong* {
fn:distinct-values(fn:data(xdmp:plan( cts:search(doc(), $QUERY ) )//qry:key))
};
local:get-keys($QUERY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment