MarkLogic directory-query with wildcard

114 Views Asked by At

I want to search in MarkLogic with using term-query in direcories that meet the pattern:

/example/*/folder/

i.e.

/example/foo/folder/
/example/foo/bar/folder/

and so on... I have something like this:

<search xmlns="http://marklogic.com/appservices/search">
  <query>
    <and-query>
      <directory-query>
        <uri>/example/*/folder/</uri>
        <depth>1</depth>
      </directory-query>
      <term-query>
        <text>some text</text>
      </term-query>
    </and-query>
  </query>
</search>

..but unfortunately <directory-query> seems not supporting wildcards in URI. Any idea how to use <directory-query> with wildcards?

1

There are 1 best solutions below

3
Mads Hansen On

You could use cts:uri-match() instead, and then apply those URIs to a cts:document-query():

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