Loading TOC...


   [$node as node()],
   [$output-kind as xs:string]
) as element()?


Return the relevance score computation report for a node.

node A node. Typically this is an item in the result sequence of a cts:search operation. If this parameter is omitted, the context node is used.
$output-kind The output kind. It can be either "element" or "object". With "element", the built-in returns an XML element. With "object", the built-in returns a map:map. The default is "element".

Usage Notes

This function returns an XML report that contains details about the score computation only if the following conditions are met: The node parameter or context node is the result of a cts:search call that included the relevance-trace option; and the score is non-zero. For example, you will not get a report if you use the score-zero option on your cts:search , if the search returns no results, or if node is not the result of cts:search .

The score computation reflects the scoring method specified in the cts:search expression, if any. The score-zero and score-random methods do not generate a report.

Collecting score computation details with which to generate this report is costly, so using the relevance-trace option will slow down your search significantly.


(: must use the relevance-trace option on cts:search to get relevance info :)
for $n in cts:search(//SPEECH,"to be or not to be", "relevance-trace")
return cts:relevance-info($n);
<qry:relevance-info xmlns:qry="http://marklogic.com/cts/query">
    <qry:score formula="scoreSum" computation="390+366+228+290">1274</qry:score>
    <qry:term weight="8.125">
      <qry:score formula="8*weight*logtf" computation="65*6">390</qry:score>
    <qry:term weight="7.625">
      <qry:score formula="8*weight*logtf" computation="61*6">366</qry:score>
    <qry:term weight="4.75">
      <qry:score formula="8*weight*logtf" computation="38*6">228</qry:score>
    <qry:term weight="3.625">
      <qry:score formula="8*weight*logtf" computation="29*10">290</qry:score>

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.