简体   繁体   English

如何在Marklogic中搜索和返回文档名称?

[英]How to search and return document name in Marklogic?

How can I search contents of documents and return the corresponding document name in Marklogic? 如何在Marklogic中搜索文档的内容并返回相应的文档名称? Suppose my document name is test.doc and it contains a text eg "hello world" . 假设我的文档名称为test.doc ,并且包含文本, 例如“ hello world” Now I am uploading this document in Marklogic Server and the content processor will generate the corresponding XML files. 现在,我将该文档上载到Marklogic Server中,内容处理器将生成相应的XML文件。 Now I am searching like this:- 现在我正在这样搜索:-

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()]

It returns the corresponding XML and XHTML file names containing the text " hello world " but I want to return only the original document name ( test.doc ) not the corresponding XML file name. 它返回包含文本“ hello world ”的相应XML和XHTML文件名,但我只想返回原始文档名( test.doc ),而不返回相应的XML文件名。

This information is not retained automatically, so you need to somehow explicitly support it in your content pipeline. 此信息不会自动保留,因此您需要以某种方式在内容管道中显式支持它。

You can modify the pipeline to store the original document name in a document property for the destination XML document, you could store the document name as metadata in the document, or you could store the original document name as part of the URI. 您可以修改管道以将原始文档名称存储在目标XML文档的文档属性中,可以将文档名称存储为文档中的元数据,也可以将原始文档名称存储为URI的一部分。

Might be out of date, but useful. 可能已过时,但很有用。

http://docs.marklogic.com/xdmp:node-uri http://docs.marklogic.com/xdmp:node-uri

xdmp:node-uri

xdmp:node-uri(
   $node as node()
) as xs:string?
Summary

Returns the document-uri property of the parameter or its ancestor. 返回参数或其祖先的document-uri属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM