Search code examples
xquerymarklogic

Xquery importing the cts ( couldn't use its functions)


I want to find distinct terms from a text using XQuery. This is my code:

declare namespace rec="http://xxx.xxx/xxx";
declare namespace cts="http://marklogic.com/cts";

for $r in /rec:Record 
return
distinctive-terms( $r/rec:text,<options xmlns="cts:distinctive-terms">  <max-terms>3</max-terms></options>)

I get the following error

1.0-ml] XDMP-UNDFUN: (err:XPST0017) Undefined function distinctive-terms()

I have changed declare namespace cts=" http://marklogic.com/cts to import module cts="http://marklogic.com/cts, but I need a location to import it from "... " I couldn't find the location of cts Anyone know what I should do??


Solution

  • cts:distinctive-terms is a built-in function, so there is no need to import a module. The cts namespace is also built in and you shouldn't need to declare it. However, you still need to use the function prefix. Just declaring it doesn't change that.

    So: cts:distinctive-terms($r/rec:text,...)