Zivilyn Bane
Zivilyn Bane

Reputation: 71

How to search a list of URIs matching a pattern in marklogic?

I'm new to XML database so i need some help with marklogic and xquery.

I did record some documents in a database and when i push explore button their URIs show up and looks like (for instance) :

/firstDirectory/documentA.xml

/firstDirectory/documentB.xml

/secondDirectory/documentC.xml

Now i want to get the list of URIs of all documents which are located in 'firstDirectory'. So i need something like that :

List<URI> unknownXQueryFunction("/firstDirectory/");

Sadly, i'm unable to find the function i need while watching into MarkLogic API. I tried some stuff with collection / document / document-uri / base-uri / directory but none did the trick :(

Any help would be greatly appreciated.

Upvotes: 3

Views: 2616

Answers (2)

wst
wst

Reputation: 11773

This applies a directory query to cts:uris, which should be a more accurate approach than cts:uri-match, depending on how your directories are organized:

cts:uris((),'document' cts:directory-query('/firstDirectory/','infinity'))

Upvotes: 5

Andrei Orlov
Andrei Orlov

Reputation: 908

Try cts:uris("/firstDirectory/", "document") if you have enabled uri lexicon.

Upvotes: 2

Related Questions