2016-03-17 28 views
2

我正在使用變換結果並在執行搜索時應用元數據摘要來提取文檔的屬性。我沒有收到物業,如果我刪除<preferred-matches>,文件說它需要返回prop-lastmodifed。但我沒有得到任何。以下是我在做什麼MarkLogic變換搜索結果選項元數據摘要

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=" 

回答

3

引述search-dev guide

的適用=「元數據 - 摘錄」選項返回指定來自屬性文件的首選元素。如果沒有指定元素,則metadata-snippet選項會爲其代碼段返回prop:last-modified元素,並且如果prop:last-modified元素不存在,它將返回一個空片段。

由於MarkLogic 6或7,最後修改的屬性不再提供開箱即用。這節省了您通常不需要的屬性片段。您可以通過管理界面啓用它。啓用內容數據庫的maintain last modified設置。我猜你沒有在數據庫中這樣做,這就是爲什麼你得到空片段的原因。

HTH!

+0

我有''爲我的所有文件的屬性,當我告訴返回''在上面的代碼..我得到空片段 – Ravi

+0

你肯定id元素是在正確的命名空間? – grtjn

+0

是的..當我寫我的自定義trasform函數它的工作原理 – Ravi