
cts:relevance-info( [$node as node()], [$output-kind as xs:string] ) as element()?
Return the relevance score computation report for a node.
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="(256*scoreSum/weightSum)+(256*qualityWeight*documentQuality)"
computation="(256*1274/4)+(256*1*0)">81536</qry:score>
<qry:confidence
formula="sqrt(score/(256*8*maxlogtf*maxidf))"
computation="sqrt(81536/(256*8*18*log(11360)))">0.486687</qry:confidence>
<qry:fitness
formula="sqrt(score/(256*8*maxlogtf*avgidf))"
computation="sqrt(81536/(256*8*18*(23.6745/4)))">0.611312</qry:fitness>
<qry:uri>hamlet.xml</qry:uri>
<qry:path>fn:doc("hamlet.xml")/PLAY/ACT[3]/SCENE[1]/SPEECH[19]</qry:path>
<qry:and>
<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:key>13470285622946442720</qry:key>
<qry:annotation>pair(word("be"),word("or"))</qry:annotation>
</qry:term>
<qry:term weight="7.625">
<qry:score formula="8*weight*logtf" computation="61*6">366</qry:score>
<qry:key>13951883977767006862</qry:key>
<qry:annotation>pair(word("or"),word("not"))</qry:annotation>
</qry:term>
<qry:term weight="4.75">
<qry:score formula="8*weight*logtf" computation="38*6">228</qry:score>
<qry:key>13642437994068421010</qry:key>
<qry:annotation>pair(word("not"),word("to"))</qry:annotation>
</qry:term>
<qry:term weight="3.625">
<qry:score formula="8*weight*logtf" computation="29*10">290</qry:score>
<qry:key>7885524737699073672</qry:key>
<qry:annotation>pair(word("to"),word("be"))</qry:annotation>
</qry:term>
</qry:and>
</qry:relevance-info>