Search code examples
marklogic

Marklogic how to retrieve text documents


How can I return a list of text documents store in DB. I use fn:document-uri() but return errors looking for node(). Thanks

13. let $uris := fn:document-uri(cts:search(fn:doc(),"sudo*","unfiltered"))
14. 
15. for $uri in $uris

[1.0-ml] XDMP-ARGTYPE: (err:XPTY0004) fn:document-uri((fn:doc("/Howto-shutdown-and-restart-AWS-DEV.txt"), fn:doc("/How-to-shutdown-restart-Oracle.txt"), fn:doc("/How-to-shutdown-restart-MYSQL.txt"))) -- arg1 is not of type node()


Solution

  • It is complaining about the fact that you passed multiple nodes to a function that expects one.

    You can either just add the function to the end of the path, so it iterates:

    cts:search(doc(),"sudo*","unfiltered")/document-uri(.)
    

    Or, since you just want the URIs from an unfiltered search, you're better off just using cts:uris directly:

    cts:uris((),(),"sudo*")