0

According to the MarkLogic docs, the "collection" parameter can appear multiple times in a GET request to the REST Client API; however, the following returns 0 results:

/LATEST/search?q=&collection=GEWN&collection=TSJN

whereas an XQuery specifying both collections on the same database does return the expected results:

count(collection(("GEWN","TSJN")))

=> 90871

Using REST API to query one named collection individually returns expected results also.

Thanks.

Shon
  • 690
  • 6
  • 22

1 Answers1

2

The collections provided by URI parameter are AND related. The equivalent provided as a query would be:

<search:query>
<search:and-query>
    <search:collection-query>
        <search:uri>GEWN</search:uri>
    </search:collection-query>
    <search:collection-query>
        <search:uri>TSJN</search:uri>
    </search:collection-query>
</search:and-query>
</search:query>

When multiple collections are passed to a single fn:collection() or cts:collection-query() call, the collections are OR related. To get the equivalent, provide the following query:

<search:query>
<search:collection-query>
    <search:uri>GEWN</search:uri>
    <search:uri>TSJN</search:uri>
</search:collection-query>
</search:query>

Here's the reference for the collection query in JSON:

http://docs.marklogic.com/guide/search-dev/structured-query#id_76890

Hoping that helps,

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
ehennum
  • 7,295
  • 13
  • 9
  • Thanks, this appears to be the case for /v1/qbe interface, but I would like to achieve this with /v1/search and the collection* parameter: http://docs.marklogic.com/REST/GET/v1/search – Shon Oct 01 '15 at 01:12
  • 1
    The structured query above works with the /v1/search endpoint. (It is not a QBE.) You can POST the structured query as a payload (with or without query text to parse) or pass the structured query with GET as the structuredQuery URL parameter. – ehennum Oct 01 '15 at 11:05
  • Excellent, thank you. I have a feeling I'll be using structured queries often moving ahead. – Shon Oct 03 '15 at 20:25