![](/img/trans.png)
[英]How to load the xhtml document as a text and search the keyword in marklogic
[英]How to search and return document name in Marklogic?
如何在Marklogic中搜索文档的内容并返回相应的文档名称? 假设我的文档名称为test.doc
,并且包含文本, 例如“ hello world” 。 现在,我将该文档上载到Marklogic Server中,内容处理器将生成相应的XML文件。 现在我正在这样搜索:-
import module namespace search="http://marklogic.com/appservices/search" at "/Marklogic/appservices/search/search.xqy";
declare variable $options:=
<options xmlns="http://marklogic.com/appservices/search">
<transform-results apply="raw"/>
</options>;
for $d in search:search("hello world", $options)/search:result
return tokenize(data($d/@uri), "/")[last()]
它返回包含文本“ hello world ”的相应XML和XHTML文件名,但我只想返回原始文档名( test.doc
),而不返回相应的XML文件名。
此信息不会自动保留,因此您需要以某种方式在内容管道中显式支持它。
您可以修改管道以将原始文档名称存储在目标XML文档的文档属性中,可以将文档名称存储为文档中的元数据,也可以将原始文档名称存储为URI的一部分。
可能已过时,但很有用。
http://docs.marklogic.com/xdmp:node-uri
xdmp:node-uri
xdmp:node-uri(
$node as node()
) as xs:string?
Summary
返回参数或其祖先的document-uri
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.