Reputation: 1048
How can I search contents of documents and return the corresponding document name in Marklogic? Suppose my document name is test.doc
and it contains a text e.g "hello world". Now I am uploading this document in Marklogic Server and the content processor will generate the corresponding XML files. 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.
Upvotes: 0
Views: 992
Reputation: 11
Might be out of date, but useful.
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.
Upvotes: 1
Reputation: 11771
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.
Upvotes: 0