我正在使用转换结果并应用元数据片段来进行搜索时提取文档的属性。我没有得到属性,如果我删除<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="
答案 0 :(得分:3)
apply =&#34; metadata-snippet&#34; option返回属性文档中指定的首选元素。如果未指定任何元素,则metadata-snippet选项将返回其片段的prop:last-modified元素,如果prop:last-modified元素不存在,则返回空片段。
自MarkLogic 6或7以来,不再提供开箱即用的最后修改属性。这节省了您经常不需要的属性片段。您可以通过管理界面启用它。启用内容数据库的maintain last modified
设置。我猜你还没有在你的数据库中做到这一点,这就是你得到空片段的原因。
HTH!