Sorry.  One more follow-up question.

This discussion started from my assumption that xdmp:eval() works but
it may not be the best way to go, and your feedback implies the same.
Why is that?  What's the issue with using xdmp:eval()?  I've been
looking in the docs and I found anything yet.



On 6/26/07, Danny Sokolsky <[EMAIL PROTECTED]> wrote:
You cannot pass that string in via XCC and have it used as a cts:query.


To make this work, you will have to move the code that parses your input
into a cts:query  from your .net/java code into your XQuery code.  For
example, you can pass in two string variables from the .net/java side:
 *  "or" to signify it is an or-query.
 *  "blues jazz" for the words to be queried.

Your XQuery module on the MarkLogic Server side might then look
something like this (this is an extremely simple query parser/generator
that simply tokenizes the input on spaces):

 define variable $query-type as xs:string external
 define variable $query as xs:string external

 let $query-tokens := fn:tokenize(fn:normalize-space($query), " ")
 let $ctsquery :=
     for $x in $query-tokens
     return
     cts:word-query($x, ("case-insensitive", "diacritic-insensitive") )
 let $newquery :=
    if ( $query-type = "or" )
    then cts:or-query($ctsquery)
    else cts:and-query($ctsquery)
 return
 <results>
   <cts-query-expr>{$newquery}</cts-query-expr>
   <search>{xdmp:estimate(cts:search(doc(), $newquery))}</search>
 </results>

and you can run this code with something like this:

 xdmp:invoke("invoke.xqy", ((xs:QName("query-type"), "or"),
                          (xs:QName("query"), "blues jazz")))

The other alternative you have is to construct the entire search on the
.net/java side, including the cts:search and the cts:query, and then
send in the whole query to execute via xcc.

-Danny

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

Reply via email to