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?
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.