How to get a list of document uri names from marklogic database?

Hi, I am trying to get a list of all document names / uri from this MarkLogic database.

I found this line in stackoverflow: How to get the total number of documents in a Marklogic database?

... which will receive the number of documents in the database. I am not sure how to change this to list all document URIs.

Also, given the document URI, I wanted to see if it exists in the database?

I tried the following but could not achieve the same

for $x in xdmp:directory("/myDirectory/", "1")
return
fn:document-uri($x)

I need an Xquery command exactly the same. I'm new to marklogic, can someone help me with this?

+4
source share
4

fn: doc() , , , URI. , URI , :

for $x in fn:doc()
   return fn:document-uri($x)

. fn:doc. , , fn:doc() URI:

fn:doc("/example/uri.xml")
+2

, , - uri, cts:uris(). uri , fn:doc(). uri ​​ true , .

, - ,

fn:doc-available("uri of document")

+9

1- ,

for $each in collection("collection-name") return fn:document-uri($each)

2- If you have the same directory structure, use

for $each in xdmp:directory("/myDirectory/", "infinity") return fn:document-uri($each)

3- If you have not used any of the above cases, you can use cts:uris() Please note that you cts:uris(), URI Lexiconmust enable it for use .

+3
source

Another way to find if a document exists:

xdmp:exists(doc("uri.xml"))
0
source

All Articles