atom feed3 messages in com.marklogic.developer.general[MarkLogic Dev General] Score-Calcula...
FromSent OnAttachments
Andreas HolzgethanAug 28, 2017 10:32 pm 
Andreas HolzgethanSep 3, 2017 11:49 pm 
Chester DavisSep 4, 2017 1:10 am 
Subject:[MarkLogic Dev General] Score-Calculation with cts:element-query
From:Andreas Holzgethan (andr@ebcont.com)
Date:Aug 28, 2017 10:32:48 pm
List:com.marklogic.developer.general

Hi everyone!

I was analyzing score calculation and found a calculation that looks unclear for me.

For example a cts:or-query without a cts:element-query returns the expected result but putting the cts:or-query into a cts:element-query returns a complete different score, regarding to element-word-query matches (with and without wildcard)

Simple example: Following document is in the database: <test> <element>test</element> </test>

When I execute the following search and get the relevance-info I will get the following result, how I expect: *Search*: cts:search( doc(), cts:or-query(( cts:element-value-query(xs:QName("element"), "test", (), 10), cts:element-word-query(xs:QName("element"), "test", (), 5), cts:element-word-query(xs:QName("element"), "tes**", (), 1) )) , ("score-simple", "relevance-trace") ) ! cts:relevance-info(.)

*Result*: <qry:relevance-info xmlns:qry="http://marklogic.com/cts/query"> <qry:score formula=" (256*scoreSum)+(scaleFactor*qualityWeight*documentQuality)" computation=" (256*128)+(256*1*0)"> 32768 </qry:score> <qry:confidence formula="sqrt(score/(256*8*weightSum))" computation=" sqrt(32768/(256*8*16))"> 1 </qry:confidence> <qry:fitness formula="sqrt(score/(256*8*weightSum))" computation=" sqrt(32768/(256*8*16))"> 1 </qry:fitness> <qry:uri> test.xml </qry:uri> <qry:path> fn:doc("test.xml") </qry:path> <qry:or> <qry:score formula="scoreSum" computation="80+40+8"> 128 </qry:score> <qry:term weight="10"> <qry:score formula="8*weight" computation="80"> 80 </qry:score> <qry:key> 15278540559134997888 </qry:key> <qry:annotation> element(element,value("test")) </qry:annotation> </qry:term> <qry:term weight="5"> <qry:score formula="8*weight" computation="40"> 40 </qry:score> <qry:key> 7623328415617434712 </qry:key> <qry:annotation> element(element,word("test")) </qry:annotation> </qry:term> <qry:term> <qry:score formula="8*weight" computation="8"> 8 </qry:score> <qry:key> 8981642353211023247 </qry:key> <qry:annotation> element(element,word("*tes*")) </qry:annotation> </qry:term> </qry:or> </qry:relevance-info>

Now running the same query with an element-query I will get the following result: *Search*: cts:search( doc(), cts:element-query(xs:QName("test"), cts:or-query(( cts:element-value-query(xs:QName("element"), "test", (), 10), cts:element-word-query(xs:QName("element"), "test", (), 5), cts:element-word-query(xs:QName("element"), "tes*", (), 1) )) ) , ("score-simple", "relevance-trace") ) ! cts:relevance-info(.)

*Result*: <qry:relevance-info xmlns:qry="http://marklogic.com/cts/query"> <qry:score formula=" (256*scoreSum)+(scaleFactor*qualityWeight*documentQuality)" computation=" (256*136)+(256*1*0)"> 34816 </qry:score> <qry:confidence formula="sqrt(score/(256*8*weightSum))" computation=" sqrt(34816/(256*8*33))"> 0.7177405 </qry:confidence> <qry:fitness formula="sqrt(score/(256*8*weightSum))" computation=" sqrt(34816/(256*8*33))"> 0.7177405 </qry:fitness> <qry:uri> test.xml </qry:uri> <qry:path> fn:doc("test.xml") </qry:path> <qry:or> <qry:score formula="scoreSum" computation="80+40+16"> 136 </qry:score> <qry:term weight="10"> <qry:score formula="8*weight" computation="80"> 80 </qry:score> <qry:key> 15278540559134997888 </qry:key> <qry:annotation> element(element,value("test")) </qry:annotation> </qry:term> <qry:and> <qry:score formula="scoreSum" computation="40+0"> 40 </qry:score> <qry:term weight="5"> <qry:score formula="8*weight" computation="40"> 40 </qry:score> <qry:key> 7623328415617434712 </qry:key> <qry:annotation> element(element,word("test")) </qry:annotation> </qry:term> <qry:term weight="0"> <qry:score formula="8*weight" computation="0"> 0 </qry:score> <qry:key> 16981665756652318861 </qry:key> <qry:annotation> word("test") </qry:annotation> </qry:term> </qry:and> <qry:and> <qry:score formula="scoreSum" computation="8+8"> 16 </qry:score> <qry:term> <qry:score formula="8*weight" computation="8"> 8 </qry:score> <qry:key> 8981642353211023247 </qry:key> <qry:annotation> element(element,word("*tes*")) </qry:annotation> </qry:term> <qry:term> <qry:score formula="8*weight" computation="8"> 8 </qry:score> <qry:key> 18357881438962379610 </qry:key> <qry:annotation> word("*tes*") </qry:annotation> </qry:term> </qry:and> </qry:or> </qry:relevance-info>

Now the score is *34816 *instead of *32768. * My question now: why are the both element-word-queries are calcuated twice in the element-query? And why is the weight "0" at the element-word-query without "*" for wildcard and why "1" with wildcard?

Best regards Andreas

HG St. Pölten - FN 293731 h UID: ATU63444589