0

I want to list all files (*.XML) in Marklogic database. How to implement such functionality in MarkLogic JavaAPI? Which works like:

cts:document-query(cts:uri-match("/directory/*/folder/*.xml"))

Related problem: MarkLogic directory-query with wildcard

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Aspir
  • 149
  • 9

1 Answers1

0

cts.documentQuery(cts.uriMatch("/directory/*/folder/*.xml"))
Is this what you are expecting? This is the server side javascript (XQuery) equivalent of what you have asked.
If you want to pass a serialized query, you should first execute cts:uri-match("/directory/*/folder/*.xml") and then enclose the results into cts:document-query as shown below

<cts:document-query xmlns:cts="http://www.w3.org/2000/xmlns/">
  <cts:uri>/directory/2019/folder/1.xml</cts:uri>
  <cts:uri>/directory/2020/folder/2.xml</cts:uri>
  <cts:uri>/directory/2021/folder/3.xml</cts:uri>
</cts:document-query>

Best approach is to create a MarkLogic module server-side (in XQuery or JS) and invoke it from JAVA client API (by passing the uri-match string)

P K
  • 162
  • 12
  • The following search-options in invalid in ML. ``` /directory/*/folder/*.xml ``` If you try using the above config, you will get this error - `XDMP-QUERYELEM: cts:query(...) -- Query element contains unknown child: /x/cts:document-query/cts:uri-match` – P K May 19 '23 at 20:46