我看到scoreSum的公式中使用qry:score表示relevance score computation
scoreSum如何计算?

谁能解释scoreSum是什么以及它是如何计算的?

<qry:score
  formula="(256*scoreSum/weightSum)+(256*qualityWeight*documentQuality)"
  computation="(256*12/1)+(256*1*0)">3072</qry:score>

最佳答案

scoreSum是查询的所有术语得分的总和。请参见以下简单示例:

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)

结果如下:
<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>

如您所见,scoreSum是术语得分(136)136+224+0pair(word("dog"),word("cat"))(224)的总和(pair(word("cat"),word("fish")))。

根据您的环境,输出可能会有所不同,具体取决于索引设置和数据库中的文档。此输出位于否则为空的数据库中,并启用了fast phrase searches(这就是为什么存在配对项的原因)。如果仅给出一个单词查询,则会在输出和scoreSum == score of your term中省略scoreSum计算。

09-05 14:28