1

How can I save the result from qconsole to output file. The output.txt will has name uri in each line below. I have over thousand of documents.

 Caltech.xml
 CGU.xml
 GMU.xml
 Hopkins.xml
 Georgetown.xml
 ....

let $uris:= cts:uris(
        (),
        (),
        cts:and-query(( cts:collection-query("/Universities/")))

    )

let $quote:=
   for $u in $uris
   return 
       fn:substring-after($u,"/Universities/")

let $output:=
text {
fn:concat(
    fn:string-join(($quote),","),
    "
"
 )

}  
return xdmp:save(fn:concat("/09122018/output.txt") ,$output) 
thichxai
  • 1,073
  • 1
  • 7
  • 16

2 Answers2

4

Don't string-join and concat to create one big string. Instead, hand in multiple strings as text nodes, wrapped in a document node that you pass into xdmp:save. You can easily handle a couple of million documents that way (provided you are willing to wait a minute). See also: https://stackoverflow.com/a/52005868/918496

If you need to scale beyond that, look at Corb2, as suggested by Rob.

HTH!

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
grtjn
  • 20,254
  • 1
  • 24
  • 35
3

You can use xdmp:save to write a file to the filesystem MarkLogic Server is using.

For sets of data too large for QConsole to handle I recommend you look at CORB.

Rob S.
  • 3,599
  • 6
  • 30
  • 39