Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can anyone explain how scoreSum is calculated in scoring

Tags:

marklogic

I see that scoreSum is used in the formula of qry:score for a relevance score computation.

How is scoreSum calculated?

Can anyone explain what scoreSum is and how it is been calculated?

<qry:score 
  formula="(256*scoreSum/weightSum)+(256*qualityWeight*documentQuality)" 
  computation="(256*12/1)+(256*1*0)">3072</qry:score>
like image 901
Raja Bhoominathan Avatar asked Dec 09 '25 05:12

Raja Bhoominathan


1 Answers

scoreSum is the sum of all term scores of your query. See the following simple example:

xquery version "1.0-ml";

let $doc := <test>dog cat fish</test>

return xdmp:document-insert("test.xml", $doc);

for $i in cts:search(doc(), cts:word-query("dog cat fish"), "relevance-trace")
return cts:relevance-info($i)

Which results in the following output:

<qry:relevance-info xmlns:qry="http://marklogic.com/cts/query">
  <qry:score formula="(256*scoreSum/weightSum)+(256*qualityWeight*documentQuality)" computation="(256*360/2)+(256*1*0)">46080</qry:score>
  <qry:confidence formula="sqrt(score/(256*8*maxlogtf*maxidf))" computation="sqrt(46080/(256*8*18*log(29)))">0.6092764</qry:confidence>
  <qry:fitness formula="sqrt(score/(256*8*maxlogtf*avgidf))" computation="sqrt(46080/(256*8*18*(5.3483/2)))">0.6836947</qry:fitness>
  <qry:uri>test.xml</qry:uri>
  <qry:path>fn:doc("test.xml")</qry:path>
  <qry:and>
    <qry:score formula="scoreSum" computation="136+224+0">360</qry:score>
    <qry:term weight="2.125">
      <qry:score formula="8*weight*logtf" computation="17*8">136</qry:score>
      <qry:key>13246596259210807488</qry:key>
      <qry:annotation>pair(word("dog"),word("cat"))</qry:annotation>
    </qry:term>
    <qry:term weight="3.5">
      <qry:score formula="8*weight*logtf" computation="28*8">224</qry:score>
      <qry:key>3660582207022472029</qry:key>
      <qry:annotation>pair(word("cat"),word("fish"))</qry:annotation>
    </qry:term>
    <qry:word>...</qry:word>
</qry:and>

As you can see scoreSum is the sum (136+224+0) of the term score (136) pair(word("dog"),word("cat")) and pair(word("cat"),word("fish"))(224).

The output might differ in your environment depending on index settings and documents in your database. This output is in a otherwise empty database and with fast phrase searches enabled (thats why there are pair terms). If only one word-query is given the scoreSum calculation is omitted in the output and scoreSum == score of your term.

like image 186
Wagner Michael Avatar answered Dec 14 '25 10:12

Wagner Michael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!