Find number of documents in a collection in Marklogic7 using Marklogic Rest API

362 Views Asked by At

I am using Marklogic 7 Rest API and I want to find out the number of documents in any collection in my Marklogic database. How can this be achieved?

1

There are 1 best solutions below

0
On BEST ANSWER

You can POST a query on the collection with a page length of 1:

{"query": { "queries": [{ "collection-query": { "uri": ["YOUR_COLLECTION"] } }] }}

http://docs.marklogic.com/REST/POST/v1/search

http://docs.marklogic.com/guide/search-dev/structured-query#id_76890

The total property in the search response will indicate the number of documents in the collection.