Hi all i am trying to get this to work using CTS queries and a user input XML string that conforms to a CTS query.
test.xqy:
let $query:=xdmp:unquote(xdmp:get-request-field('query'))
let $results:=cts:search(/,$query)
return
<r>
<q>
{$query}
</q>
{$results}
</r>
query will be
<cts:element-value-query>
<cts:element>date</cts:element>
<cts:text xml:lang="en">2013-11-18</cts:text>
</cts:element-value-query>
What i dont understand is how come there are always no results. Using replacing $query with
let $query:=cts:element-value-query(xs:QName("date"),"2013-11-18")
always works.
So i dont understand whats the difference between a custom xml string converted with xdmp:unquote
is any different from a cts:element-value-query
. I have printed both of them out and they are the same.
http://docs.marklogic.com/cts:search takes a cts:item
not an XML element. If xdmp:get-request-field('query')
is expected to return serialized cts:query XML, try this:
`cts:query(xdmp:unquote(xdmp:get-request-field('query'))/*)`
The /*
step is necessary because xdmp:unquote
returns a document node.