Hi again Danny,

I appreciate the feedback but I don't think that's the problem. I believe I've 
isolated the issue to the constructor for the cts:or-query. If I try the 
following scenario where I am searching for some query text in both English and 
German using just the cts:or-query (forget the element-query for now):

$queryText := "pa",
$engOptions :=
<options xmlns="http://marklogic.com/appservices/search";>
                                <term apply="term">
                                                <empty apply="all-results"/>
                                                
<term-option>lang=en</term-option>
                                </term>
                </options>,
$deOptions :=
<options xmlns="http://marklogic.com/appservices/search";>
                                <term apply="term">
                                                <empty apply="all-results"/>
                                                
<term-option>lang=de</term-option>
                                </term>
                </options>,
$engQuery := search:parse($queryString, $engOptions),
$deQuery := search:parse($queryString, $deOptions),
$query := cts:or-query(($engQuery, $deQuery)),
return search:resolve($query)

I keep getting an Internal Server Error for the second to last line "$query := 
cts:or-query(($engQuery, $deQuery))" and the error message is: 
"XDMP-NONMIXEDCOMPLEXCONT: fn:data(<cts:word-query qtextref="cts:text" 
xmlns:cts="http://marklogic.com/cts";><cts:text 
xml:lang="en">pa</cts:text></cts:word-query>) -- Node has complex type with 
non-mixed complex content"

In the documentation for the cts:or-query constructor it states that the 
function takes a sequence of cts:querys for input and the documentation for 
search:parse says that the function returns the appropriate cts:query XML. So 
it seems the problem is that in constructing the cts:or-query I am providing 
cts:query XML instead of cts:query nodes? Does this make sense? I've tried 
wrapping the results of the search:parse faunction in cts:query constructors 
like this: cts:or-query((cts:query($engQuery), cts:query($deQuery))). This 
accomplished nothing.

Adam


From: [email protected] 
[mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: April 14, 2010 2:39 PM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] RE: Noobie cts:element-query question

Hi Gary,

I think the problem is that search:resolve does not take a cts:query, but takes 
the XML representation of a cts:query-- schema-element(cts:query).  So wrap it 
in an xml constructor and take the contents of it:

search:resolve(<foo>{$query}</foo>/*, $ searchOptions, $start, $pageLength)

-Danny



From: [email protected] 
[mailto:[email protected]] On Behalf Of Adam Patterson
Sent: Wednesday, April 14, 2010 6:53 AM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] RE: Noobie cts:element-query question

Thanks Danny,

I still cannot construct my element query, but for a different reason now. I've 
tried to include the full query in my example this time for clarity:

                $engQuery := search:parse("pa", <options 
xmlns="http://marklogic.com/appservices/search";>
                                                                                
                <term apply="term">
                                                                                
                                <empty apply="all-results"/>
                                                                                
                                <term-option>lang=en</term-option>
                                                                                
                </term>
                                                                                
   </options>),
                $deQuery := search:parse("pa", <options 
xmlns="http://marklogic.com/appservices/search";>
                                                                                
                <term apply="term">
                                                                                
                                <empty apply="all-results"/>
                                                                                
                                <term-option>lang=de</term-option>
                                                                                
                </term>
                                                                                
   </options>),
                $query := 
cts:element-query(fn:QName("http://www.tei-c.org/ns/1.0";, "div"), 
cts:or-query(($engQuery, $deQuery))),
                $searchOptions :=           <options 
xmlns="http://marklogic.com/appservices/search";>
                                                                                
<debug>{fn:true()}</debug>
                                                                                
<return-query>{fn:true()}</return-query>
                                                                                
                
<additional-query>{cts:document-query(c:DB_URI())}</additional-query>
                                                                </options>
                $results := search:resolve($query, $ searchOptions, $start, 
$pageLength)

The output is a 500 Internal Server Error. The error message is: 
"XDMP-NONMIXEDCOMPLEXCONT: fn:data(<cts:word-query qtextref="cts:text" 
xmlns:cts="http://marklogic.com/cts";><cts:text 
xml:lang="en">pa</cts:text></cts:word-query>) -- Node has complex type with 
non-mixed complex content".

It looks like the fn:data function does not like the cts:word-query returned by 
search:parse with the language term-option set to "en"...this confuses me. 
Incidentally, the cts:or-query works fine if I do not try to constrain it to 
the "div" element with the cts_element-query. Any thoughts are appreciated.

Cheers,
Adam

From: [email protected] 
[mailto:[email protected]] On Behalf Of Danny Sokolsky
Sent: April 13, 2010 5:12 PM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] RE: Noobie cts:element-query question

Hi Adam,

It is telling you that the XML for your cts:query is not correct.

Note that you were not building a cts:element-query, but were building an XML 
representation of a cts:element-query.

You might try constructing this query as a cts:query like this:

xquery version "1.0-ml";

let $engQuery := "dog"
let $deQuery := "cat"
return
cts:element-query(
       fn:QName("http://www.tei-c.org/ns/1.0";, "div"),
       cts:or-query(($engQuery, $deQuery))
)

and if you need the XML representation of a cts:query then wrap the cts:query 
in an element and take the contents of that element:

xquery version "1.0-ml";

let $engQuery := "dog"
let $deQuery := "cat"
return
<foo>{cts:element-query(
       fn:QName("http://www.tei-c.org/ns/1.0";, "div"),
       cts:or-query(($engQuery, $deQuery))
)}</foo>/*

-Danny

From: [email protected] 
[mailto:[email protected]] On Behalf Of Adam Patterson
Sent: Tuesday, April 13, 2010 2:03 PM
To: [email protected]
Subject: [MarkLogic Dev General] Noobie cts:element-query question

I apologize in advance for this question as I'm sure it's very straightforward, 
but it does have me stumped. I am building a cts:element-query as follows:

<cts:element-query>
{
                fn:QName("http://www.tei-c.org/ns/1.0";, "div"),
                <cts:or-query>{$engQuery, $deQuery}</cts:or-query>
}
</cts:element-query>

MarkLogic is telling me that I have the following error:

"XDMP-QUERYTEXT: cts:query(<cts:and-query 
xmlns:cts="http://marklogic.com/cts";><cts:element-query 
xmlns:tei="http://www.tei-c.org/ns/1.0";>tei:d...</cts:and-query>) -- Query 
element /cts:and-query/cts:element-query contains misplaced text"

Please let me know (1) What this error means, and (2) What I'm doing wrong to 
cause it.

Thank you,

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

Reply via email to