[MarkLogic Dev General] re:Query By Example
Runstein, Robert E. (Contr) (IS)
Robert.Runstein at ngc.com
Tue Feb 16 08:45:44 PST 2010
Hi Justin,
Yes, constructing the query as a literal as you suggested works, but I'm
wondering how I can call search:resolve if I've constructed the query as
a cts:and-query using the cts functions rather than using a literal or
constructing elements for each component of the query. The query I've
constructed using the cts functions works in cts:search and as an
additional-query passed as a search:options to search:search. Short of
rewriting my code to return the query as a literal in the form below, is
there a way to convert the cts:and-query to a form that will be accepted
by search:resolve?
Since the query built with the cts functions does work as an
additional-query passed as a search:option to search:search, is there
any benefit to using search:resolve over search:search?
Bob
------------------------------------------------------------------------
-----------------------
Bob,
It sounds like you're passing XML to something that's expecting a
string. Please give this a try:
xquery version "1.0-ml";
import module namespace search =
"http://marklogic.com/appservices/search"
at "/MarkLogic/appservices/search/search.xqy";
let $q := <cts:and-query xmlns:cts="http://marklogic.com/cts">
<cts:element-query>
<cts:element>MyElementName</cts:element>
<cts:and-query>
<cts:element-attribute-value-query>
<cts:element>MyElementName</cts:element>
<cts:attribute>MyAttributeName</cts:attribute>
<cts:text xml:lang="en">text_to_match</cts:text>
</cts:element-attribute-value-query>
</cts:and-query>
</cts:element-query>
</cts:and-query>
return search:resolve($q)
Justin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xqzone.marklogic.com/pipermail/general/attachments/20100216/149ec696/attachment.html
More information about the General
mailing list