我正在使用转换结果并应用元数据片段来在搜索时提取文档的属性。我没有获得属性,而且如果我删除 <preferred-matches>
,文档说它需要返回 prop-lastmodifed。但我没有得到任何。以下是我正在做的事情
xquery version "1.0-ml";
declare namespace html = "http://www.w3.org/1999/xhtml";
declare namespace prop = "http://marklogic.com/xdmp/property";
declare namespace meta = "http://ir.abbivenet.com/content-repo/metadata";
import module namespace search = "http://marklogic.com/appservices/search" at "/MarkLogic/appservices/search/search.xqy";
let $q := "(TNF)"
let $options :=
<options xmlns="http://marklogic.com/appservices/search">
<term>
<term-option>case-insensitive</term-option>
<term-option>punctuation-insensitive</term-option>
<term-option>whitespace-insensitive</term-option>
<term-option>wildcarded</term-option>
</term>
<transform-results apply="metadata-snippet">
<preferred-matches>
<element ns="http://ir.abbivenet.com/content-repo/metadata" name="id"/>
</preferred-matches>
</transform-results>
<!--
<return-facets>false</return-facets>
<return-values>false</return-values>
<return-constraints>false</return-constraints>
<return-frequencies>false</return-frequencies>
<return-qtext>false</return-qtext>
<search-option>unfaceted</search-option>
<search-option>score-simple</search-option>
-->
</options>
let $start := 1
let $page-length :=1000000
let $query-original := cts:query(search:parse($q, $options))
let $result := search:resolve(document { $query-original }/*,
$options,
$start,
$page-length)
return $result
以下是我的结果片段
<search:response snippet-format="metadata-snippet" total="546" start="1" page-length="1000000" xmlns:search="http://marklogic.com/appservices/search">
<search:result index="1"
uri="/documents/BioEln/79ca10522ef2bd3da946623c8dd1f5c6c786d983.xml/extractedText/79ca10522ef2bd3da946623c8dd1f5c6c786d983.xhtml"
path="fn:doc("/documents/BioEln/79ca10522ef2bd3da946623c8dd1f5c6c786d983.xml/extractedText/79ca10522ef2bd3da946623c8dd1f5c6c786d983.xhtml")"
score="246272" confidence="0.7858079" fitness="1">
<search:snippet>
<search:match
path="fn:doc("/documents/BioEln/79ca10522ef2bd3da946623c8dd1f5c6c786d983.xml/extractedText/79ca10522ef2bd3da946623c8dd1f5c6c786d983.xhtml")">
</search:match>
</search:snippet>
</search:result>
<search:result index="2"
uri="/documents/BioEln/568819dbbf44a75598739e8272d0de5956dadff4.xml/extractedText/568819dbbf44a75598739e8272d0de5956dadff4.xhtml"
path="fn:doc("/documents/BioEln/568819dbbf44a75598739e8272d0de5956dadff4.xml/extractedText/568819dbbf44a75598739e8272d0de5956dadff4.xhtml")"
score="246272" confidence="0.7858079" fitness="1">
<search:snippet>
<search:match path="fn:doc("/documents/BioEln/568819dbbf44a75598739e8272d0de5956dadff4.xml/extractedText/568819dbbf44a75598739e8272d0de5956dadff4.xhtml")">
</search:match>
</search:snippet>
</search:result>
<search:result index="3" uri="
最佳答案
引用search-dev guide :
The apply="metadata-snippet" option returns the specified preferred elements from the properties documents. If no element is specified, then the metadata-snippet option returns the prop:last-modified element for its snippet, and if the prop:last-modified element does not exist, it returns an empty snippet.
自 MarkLogic 6 或 7 起,不再提供开箱即用的最后修改属性。这可以节省您通常不需要的属性片段。您可以通过管理 UI 启用它。启用内容数据库的维护上次修改
设置。我猜您还没有在数据库中执行此操作,这就是您得到空片段结果的原因。
呵呵!
关于MarkLogic 转换搜索结果选项元数据片段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36066026/