I am trying to do the following
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
let $options := <options xmlns="http://marklogic.com/appservices/search">
<additional-query>
<cts:collection-query xmlns:cts="http://marklogic.com/cts">
<cts:uri>http://ir.abbvienet.com/content-repo/type/envelope</cts:uri>
</cts:collection-query>
</additional-query>
<constraint name="gene">
<range type="xs:string" facet="true">
<path-index>//Hit[@type='GENE']/@id</path-index>
<facet-option>frequency-order</facet-option>
<facet-option>descending</facet-option>
<facet-option>limit=10</facet-option>
</range>
</constraint>
</options>
return
$options//search:constraint[@name='gene']
When I do this in query console it works fine.. but when I do the same in my REST extension, I get the following error
<error:xquery-version>1.0-ml</error:xquery-version>
<error:message>Node has complex type with non-mixed complex content</error:message>
<error:format-string>XDMP-NONMIXEDCOMPLEXCONT: fn:data(<constraint name="gene" xmlns="http://marklogic.com/appservices/search"><range type="xs:string" facet="true"><path-index>//Hit[@type='GE...</constraint>) -- Node has complex type with non-mixed complex content</error:format-string>
<error:retryable>false</error:retryable>
<error:expr>fn:data(<constraint name="gene" xmlns="http://marklogic.com/appservices/search"><range type="xs:string" facet="true"><path-index>//Hit[@type='GE...</constraint>)</error:expr>
<error:data/>
<error:stack>
Any ideas on why this is the case ?
**** EDIT Added my REST extension below *************
module namespace repoTest = "http://marklogic.com/rest-api/resource/repoTest";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
declare default function namespace "http://www.w3.org/2005/xpath-functions";
declare option xdmp:mapping "false";
(: Function responding to GET method - must use local name 'get':)
declare function repoTest:get($context as map:map, $params as map:map) as document-node()*
{
let $out :=
try{
let $options := <options xmlns="http://marklogic.com/appservices/search">
<constraint name="gene">
<range type="xs:string" facet="true">
<path-index>//Hit[@type='GENE']/@id</path-index>
<facet-option>frequency-order</facet-option>
<facet-option>descending</facet-option>
<facet-option>limit=10</facet-option>
</range>
</constraint>
</options>
let $facetContraint := $options//search:constraint[@name='gene']
let $_ := xdmp:log("facetContraint :" || $facetContraint)
return $facetContraint
}catch($ex) {
let $log := xdmp:log("ERROR !!!!!")
let $log := xdmp:log($ex)
return ()
}
return document { $out }
};
(: Function responding to PUT method - must use local name 'put'. :)
declare function repoTest:put($context as map:map, $params as map:map, $input as document-node()*) as document-node()?
{
repoTest:notSupportedMsg($context)
};
(: Func responding to DELETE method - must use local name 'delete'. :)
declare function repoTest:delete($context as map:map,$params as map:map) as document-node()?
{
repoTest:notSupportedMsg($context)
};
(: Function responding to POST method - must use local name 'post'. :)
declare function repoTest:post($context as map:map, $params as map:map,$input as document-node()*) as document-node()*
{
repoTest:notSupportedMsg($context)
};
declare private function repoTest:notSupportedMsg($context as map:map) as document-node()*
{
let $_ := map:put($context, "output-status", (501, "Not Supported HTTP method"))
let $output := json:object()
let $errorResponse := json:object()
let $_ := (
map:put($errorResponse, "statusCode", 501),
map:put($errorResponse, "message", "Not Supported HTTP method")
)
let $dummpy := map:put($output, "errorResponse", $errorResponse )
return document {xdmp:to-json($output)}
};
format=jsonparameter? That could trigger some automatic conversion logic, and that is probably not anticipating XML, in particular XML in search namespace? - grtjncurl -u reader:reader http://10.239.12.85:8042/LATEST/resources/repoTest- Ravi