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 -d...@options.xml  -Hcontent-type:application/xml 
http://xxx:port/v1/values/collections


https://docs.marklogic.com/REST/POST/v1/values/[name]

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
cgr...@marklogic.com
Cell:  +1 707 318 0442
@grechaw
www.marklogic.com

________________________________
From: general-boun...@developer.marklogic.com 
[general-boun...@developer.marklogic.com] on behalf of Bhushan Suryawanshi 
[bsuryawan...@xenomorph.com]
Sent: Wednesday, January 04, 2017 1:37 PM
To: general@developer.marklogic.com
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
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to