0
votes

I have an XQuery that searches for XML documents that have a specific property value (metadata) associated with it. The query below works in the Q Console, however I need to execute it as a GET call using the REST API:

cts:search( fn:collection(), cts:properties-query(cts:element-value-query(xs:QName("type"),"executable")))

How do I convert this XQuery to a REST call that will return the same results?

2

2 Answers

2
votes

This was resolved using the following query:

<query xmlns="http://marklogic.com/appservices/search">
<properties-fragment-query>
<value-query><element name="type" ns=""/>
    <text>executable</text>
</value-query></properties-fragment-query>
</query>

I HTTP encoded this query and appended it to the REST call like this:

http://localhost:xxxx/v1/search?structuredQuery=encoded query

1
votes

Send a GET request to the /v1/search endpoint with a structuredQuery parameter set to the HTTP encoded a JSON or XML representation of a properties fragment query containing a value query on an element. See: