Warm tip: This article is reproduced from serverfault.com, please click

Marklogic Query to fetch all the documents present in database

发布于 2017-12-15 10:09:40

I want to know the query to fetch all the documents present in database. I am aware of the query which will fetch the documents present under a particular folder. Below is the example for the same(getting count).

fn.count(xdmp.directory(["/dir1/"],"1"));

But I want to know how to fetch all documents in the database.

Questioner
Sukesh
Viewed
0
Mads Hansen 2017-12-16 02:39:59

You could use the following to count all of the documents:

fn.count(fn.doc())

Or you could use cts.estimate() for a fast estimate of a search for document fragments:

cts.estimate(cts.trueQuery(), 'document')

Applying that criteria to cts.search():

cts.search(cts.trueQuery(), 'document')