Full text score with or

Thursday, 10 April 2014 · 4 messages · last reply 23 Nov 2014
AB
Andy Bunce10 Apr 2014 18:27 #
Hi, I want to score searches with multiple conditions e.g.
let $data:=(
  <r><a>red apple</a></r>,
  <r><a>blue lagoon</a></r>,
  <r><b>fish and chips</b></r>)
for $hit score $s in $data[ a contains text("red") or b contains text("fish")] return $s In 7.8.2 it always returns scores of zero. In version 7.6 it returns numbers like 0.6201145069582775 0.4528324252639413 Is this bug? Regards /Andy
CG
Christian Grün11 Apr 2014 13:04 #
Hi Andy, as we haven't managed so far to formalize scoring propagation for all XQuery expressions, and as we thought that XQuery itself can also be used to combine score values, we have recently decided to reduce our scoring to the most essential operation (namely, "contains text"). One solution to get this working again is:
  let $data:= (
    <r><a>red apple</a></r>,
    <r><a>blue lagoon</a></r>,
    <r><b>fish and chips</b></r>
  )
  for $hit in $data
  let score $a := $hit/a contains text "red"
  let score $b := $hit/b contains text "fish"
  let $score := ($a + $b) div 2
  where $score
  return $hit
The advantage is that you can decide by yourself how you want to combine scores. The drawback, obviously, is that your code gets more complex. Best, Christian
Quoted text · Andy Bunce · 22 lines
On Thu, Apr 10, 2014 at 6:27 PM, Andy Bunce <bunce.andy at gmail.com> wrote: > Hi, > > I want to score searches with multiple conditions e.g. > > let $data:=( > <r><a>red apple</a></r>, > <r><a>blue lagoon</a></r>, > <r><b>fish and chips</b></r>) > > for $hit score $s in $data[ > a contains text("red") > or b contains text("fish")] > > return $s > > In 7.8.2 it always returns scores of zero. > In version 7.6 it returns numbers like 0.6201145069582775 0.4528324252639413 > > Is this bug? > Regards > /Andy
AB
Andy Bunce16 Apr 2014 14:09 #
Hi Christian, Thanks, that works for me. I always prefer less complex code :-) so it would be nice if this feature made a return at some point. Regards /Andy On Fri, Apr 11, 2014 at 12:04 PM, Christian Grün <christian.gruen at gmail.com>wrote:
Quoted text · Christian Grün · 54 lines
> Hi Andy, > > as we haven't managed so far to formalize scoring propagation for all > XQuery expressions, and as we thought that XQuery itself can also be > used to combine score values, we have recently decided to reduce our > scoring to the most essential operation (namely, "contains text"). > > One solution to get this working again is: > > let $data:= ( > <r><a>red apple</a></r>, > <r><a>blue lagoon</a></r>, > <r><b>fish and chips</b></r> > ) > for $hit in $data > let score $a := $hit/a contains text "red" > let score $b := $hit/b contains text "fish" > let $score := ($a + $b) div 2 > where $score > return $hit > > The advantage is that you can decide by yourself how you want to > combine scores. The drawback, obviously, is that your code gets more > complex. > > Best, > Christian > > > > On Thu, Apr 10, 2014 at 6:27 PM, Andy Bunce <bunce.andy at gmail.com> wrote: > > Hi, > > > > I want to score searches with multiple conditions e.g. > > > > let $data:=( > > <r><a>red apple</a></r>, > > <r><a>blue lagoon</a></r>, > > <r><b>fish and chips</b></r>) > > > > for $hit score $s in $data[ > > a contains text("red") > > or b contains text("fish")] > > > > return $s > > > > In 7.8.2 it always returns scores of zero. > > In version 7.6 it returns numbers like 0.6201145069582775 > 0.4528324252639413 > > > > Is this bug? > > Regards > > /Andy >
CG
Christian Grün23 Nov 2014 22:50 #
Hi Andy,
Quoted text · Andy Bunce · 2 lines
> Thanks, that works for me. I always prefer less complex code :-) so it would > be nice if this feature made a return at some point.
So it did: In the latest snapshot, scores will again be propagated when using and, or, and predicates [2]. Cheers, Christian [1] http://files.basex.org/releases/latest/ [2] http://docs.basex.org/wiki/Full-Text#Scoring

⚡Generated with XQuery