我试图将我的搜索结果转换为使用XQuery的某种其他格式。我使用的例子XQuery转换像文档:Xquery转换错误“无效强制()作为文档节点()”
xquery version "1.0-ml";
module namespace example = "http://marklogic.com/rest-api/transform/add-attr";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
declare function example:transform(
$context as map:map,
$params as map:map,
$content as document-node()
) as document-node()
{
let $searchResult := $content
let $docs := fn:doc($searchResult/search:result/@uri)
return $docs
};
安装改造使用
curl --anyauth --user user:password -X PUT [email protected]"./add-attr.xqy" -H "Content-type: application/xquery" 'http://IP-ADD:port/LATEST/config/transforms/add-attr?trans:name=string\?&trans:value=string\?'
现在,当我尝试搜索任何字符串变换一样:
http://IP-ADD:port/v1/search?q=xyz&transform=add-attr
我收到以下错误:
<rapi:error
xmlns:rapi="http://marklogic.com/rest-api">
<rapi:status-code>500</rapi:status-code>
<rapi:status>INTERNAL ERROR</rapi:status>
<rapi:message-code>XDMP-AS</rapi:message-code>
<rapi:message>XDMP-AS: (err:XPTY0004) $service($context, $service-params, $input) -- Invalid coercion: ("{&quot;root&quot;:{&quot;claim&quot;:[{&quot;type&quot;:&quot;In...", ",") as document-node(). See the MarkLogic server error log for further detail.</rapi:message>
</rapi:error>
我试图将每个文档转换为JSON转换函数中的搜索结果(我没有包含上面的代码)。 我错过了什么?我错在哪里?你能帮我解决吗?
由于提前,
大地
中提供扩展功能(变换)脚注:可以直接读取查询结果文档没有如http://docs.marklogic.com/guide/rest-dev/bulk#id_65903中所述的变换 – ehennum