Hi Justin,

Sorry for the delay in responding, but I was out of town most of last
week.

Your suggestion below worked for me with one exception.  I get
XDMP-INVQUERY unless I add an additional cts:word-query with an empty
cts:text element which should not be allowed according to the current
API docs.  I'm using version 4.1-2. Was there a change to the
search:resolve code after that version that would account for this?  The
below code is working for me.

let $q := <cts:and-query xmlns:cts="http://marklogic.com/cts";>
  <cts:element-query>
    <cts:element>MyElementName</cts:element>
     <cts:word-query><cts:text/></cts:word-query>
    <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>{$q}</q>/element())

Bob

------------------------------------------------------------------------
-----------------------
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())

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to