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>
(: must use the relevance-trace option on cts:search to get relevance info The BM25 scoring method has additional variables in the score calculation: length: the length of the resultant document bm25lw: the weight of the resultant document's length on the score calculation avgdl: the average length of all documents in the target database :) let $result := cts:search(fn:doc(),"animals", ("relevance-trace","score-bm25","bm25-length-weight=0.75")) return cts:relevance-info(fn:head($result)); => <qry:relevance-info xmlns:qry="http://marklogic.com/cts/query"> <qry:score formula="(256*scoreSum/weightSum)+(256*qualityWeight*documentQuality)" computation="(256*354/1)+(256*1*0)">90624</qry:score> <qry:confidence formula="sqrt(score/(256*8*maxlogtf*maxidf))" computation="sqrt(90624/(256*8*18*log(7162)))">0.5262576</qry:confidence> <qry:fitness formula="sqrt(score/(256*8*maxlogtf*avgidf))" computation="sqrt(90624/(256*8*18*(7.26711/1)))">0.5816204</qry:fitness> <qry:uri>/VGFHNOBGUOFGIGTX/20161171439249/4/311R.xml</qry:uri> <qry:path>fn:doc("/VGFHNOBGUOFGIGTX/20161171439249/4/311R.xml")</qry:path> <qry:term weight="7.375"> <qry:score formula="8*weight*round(logtf/(length/avgdl*bm25lw+(1-bm25lw)))" computation="59*round(5/(9080/10799.3*0.75+(1-0.75)))" resolution="59*6">354</qry:score> <qry:key>17161663675614076798</qry:key> <qry:annotation>word("animals")</qry:annotation> </qry:term> </qry:relevance-info>
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.