Hi Wayne,
Thanks for your response.
I’m still having difficulty with this. If I do the following as suggested:
...
$englishQuery := search:parse($queryString, $englishOptions),
$germanQuery := search:parse($queryString, $germanOptions),
$results :=
search:resolve(cts:or-query((cts:query($englishQuery),
cts:query($germanQuery))), bhccSearch:getSearchOptions($target, $page))
return ...
Then I get the following error:
XDMP-AS: (err:XPTY0004) $ctsquery as element() -- Invalid coercion:
cts:or-query((cts:word-query("pa", ("lang=en"), 1), cts:word-query("pa",
("lang=de"), 1))) as element()
It looks like search:resolve is expecting a cts:query element, but the return
value of the cts:or-query is returning something which cannot be cast as a
cts:query element. Any thoughts?
Adam
From: [email protected]
[mailto:[email protected]] On Behalf Of Wayne Feick
Sent: March 19, 2010 2:25 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Invalid coercion and cts:query
Hi Adam,
You don't need that cts:query() wrapper around everything, just use the
cts:or-query() directly.
The cts:query() function creates a query from an XML representation of it (e.g.
if you had placed a query into a document).
Wayne.
On Fri, 2010-03-19 at 11:06 -0700, Adam Patterson wrote:
Hi, newbie to XQuery and Marklogic here. I’m trying to do something like the
following:
...
$englishQuery := search:parse($queryString, $englishOptions),
$germanQuery := search:parse($queryString, $germanOptions),
$query := cts:query( cts:or-query((cts:query($englishQuery),
cts:query($germanQuery)))),
$results := search:resolve($query,
bhccSearch:getSearchOptions($target, $page))
return ...
I have content which is English, and other content which is German, and I am
trying to build queries which will search both the English and German content,
and then build a cts:or-query from those, and finally build a cts:query from
the cts:or-query which I can use with search:resolve to return results. I keep
getting errors like this:
XDMP-ARGTYPE: (err:XPTY0004) cts:query(cts:or-query((cts:word-query("pa",
("lang=en"), 1), cts:word-query("pa", ("lang=de"), 1)))) -- arg1 is not of type
element()
So I guess the cts:or-query constructor is not returning me an element as
needed by the cts:query constructor. Can someone explain why this is and how I
should handle this?
Cheers,
Adam
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general