Reputation: 1179
I am using transform results and apply metadata-snippet to extract a property of documents when doing a search. I am not getting the properties and also if I remove the <preferred-matches>
, the documentation says it needs to return prop-lastmodifed. But I am not getting any. Following is what I am doing
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
Following is the snippet of my results
<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="
Upvotes: 2
Views: 207
Reputation: 20414
To quote the 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.
Since MarkLogic 6 or 7, last-modified property is not provided out of the box any more. That saves on properties fragments you often don't need. You can enable it via the Admin UI. Enable the maintain last modified
setting of your content database. I am guessing you haven't done that in your database, which is why you are getting the empty snippet as result.
HTH!
Upvotes: 3