Hi Charles,

Thanks for your prompt reply.

Both of the below suggestions provided works for me.

Thanks & Regards,
Bhushan Suryawanshi

From: [email protected] 
[mailto:[email protected]] On Behalf Of Charles Greer
Sent: Wednesday, January 4, 2017 4:47 PM
To: MarkLogic Developer Discussion <[email protected]>
Subject: Re: [MarkLogic Dev General] List of all the collections in the 
database using REST api

Hi Bhushan,

What you're looking for is a call to /v1/values to fetch the collection lexicon.

For XQuery, the code you included would not scale, what you'll want is 
something calling
cts:collections()

>From REST, you need an options file and a call to get a named collection

options.xml:

<options xmlns="http://marklogic.com/appservices/search";>

    <values name="collections">

        <collection/>

    </values>

</options>


curl -X POST [email protected]<mailto:[email protected]>  
-Hcontent-type:application/xml http://xxx:port/v1/values/collections


https://docs.marklogic.com/REST/POST/v1/values/[name]<https://docs.marklogic.com/REST/POST/v1/values/%5bname%5d>

A second way is to use the fact that, in MarkLogic, named graphs are 
implemented as collections.  So

curl http://xxx:port/v1/graphs

happens to list all the collections in the database too.

I think I've got that all right, see if it helps,

Charles Greer
Lead Engineer
MarkLogic Corporation
[email protected]<mailto:[email protected]>
Cell:  +1 707 318 0442
@grechaw
www.marklogic.com<http://www.marklogic.com>
________________________________
From: 
[email protected]<mailto:[email protected]>
 [[email protected]] on behalf of Bhushan Suryawanshi 
[[email protected]]
Sent: Wednesday, January 04, 2017 1:37 PM
To: [email protected]<mailto:[email protected]>
Subject: [MarkLogic Dev General] List of all the collections in the database 
using REST api
Hello Guys,

I was working on MarkLogic 8 using REST API. I want to retrieve all the 
collections associated with the documents in the database.
After going through search documents, We can use the following code:

let $collections := for $doc in fn:doc()
                           return
xdmp:document-get-collections(fn:base-uri($doc))
return fn:distinct-values($collections)

The above code returns the exact results, Can we get the same results using 
REST api.

Any help would be greatly appreciated.


Bhushan Suryawanshi
Developer
t: +1-212-401-7894
www.xenomorph.com<http://www.xenomorph.com/?mail> | 
blog<http://xenomorph.typepad.com/?mail> | twitter<http://goo.gl/oaBWO> | 
linkedin<http://goo.gl/rdi8W>


This email is confidential and is intended only for the addressee. If you are 
not the intended recipient, please note that any dissemination, distribution or 
copying of this email is strictly prohibited. Any and all estimates, proposals, 
quotes and fees contained herein are for discussion purposes only and are not 
contractually binding unless executed in accordance with the standard practices 
of the Company. Attachments to this message have been virus checked but no 
guarantee can be made that any attachment is virus free. Please notify us 
immediately of any problem.



_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to