Bob, search:resolve is designed as a complement to search:parse. The latter gives you an annotated cts:query serialized as XML from a string, appropriate for passing to search:resolve. If you're using search:resolve without search:parse, for example constructing your own cts:query, you'll have to serialize the query as XML first. To serialize a cts:query you just need to wrap it with an element. I've pasted an example below.
Justin xquery version "1.0-ml"; import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy"; let $q as cts:query := cts:and-query( (cts:element-query(xs:QName("MyElementName"), cts:and-query("asdf"))) ) return search:resolve(<q>{$q}</q>/element()) Justin Makeig Product Manager Mark Logic Corporation 999 Skyway Road Suite 200 San Carlos, CA 94070 +1 650 655 2387 Phone [email protected]<mailto:[email protected]> www.marklogic.com<http://www.marklogic.com/> <http://www.marklogic.com/><http://www.marklogic.com/> This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation. On Feb 16, 2010, at 8:45 AM, Runstein, Robert E. (Contr) (IS) wrote: 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 _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
