- #process parenthesis before.
- if ($string =~ /^\s*\((.*)\)(( and | or | not | AND | OR | NOT )(.*))?/){
- my $left = $1;
- my $right = $4;
- my $operator = lc($3); # FIXME: and/or/not are operators, not operands
- warn "dealing w/parenthesis before recursive sub call. left :$left operator:$operator right:$right" if $DEBUG;
- my $leftresult = NZanalyse($left,$server);
- if ($operator) {
- my $rightresult = NZanalyse($right,$server);
- # OK, we have the results for right and left part of the query
- # depending of operand, intersect, union or exclude both lists
- # to get a result list
- if ($operator eq ' and ') {
- my @leftresult = split /;/, $leftresult;
- warn " @leftresult / $rightresult \n" if $DEBUG;
-# my @rightresult = split /;/,$leftresult;
- my $finalresult;
- # parse the left results, and if the biblionumber exist in the right result, save it in finalresult
- # the result is stored twice, to have the same weight for AND than OR.
- # example : TWO : 61,61,64,121 (two is twice in the biblio #61) / TOWER : 61,64,130
- # result : 61,61,61,61,64,64 for two AND tower : 61 has more weight than 64
- foreach (@leftresult) {
- my $value=$_;
- my $countvalue;
- ($value,$countvalue)=($1,$2) if $value=~m/(.*)-(\d+)$/;
- if ($rightresult =~ /$value-(\d+);/) {
- $countvalue=($1>$countvalue?$countvalue:$1);
- $finalresult .= "$value-$countvalue;$value-$countvalue;";
+
+ #process parenthesis before.
+ if ( $string =~ /^\s*\((.*)\)(( and | or | not | AND | OR | NOT )(.*))?/ ) {
+ my $left = $1;
+ my $right = $4;
+ my $operator = lc($3); # FIXME: and/or/not are operators, not operands
+ warn
+"dealing w/parenthesis before recursive sub call. left :$left operator:$operator right:$right"
+ if $DEBUG;
+ my $leftresult = NZanalyse( $left, $server );
+ if ($operator) {
+ my $rightresult = NZanalyse( $right, $server );
+
+ # OK, we have the results for right and left part of the query
+ # depending of operand, intersect, union or exclude both lists
+ # to get a result list
+ if ( $operator eq ' and ' ) {
+ my @leftresult = split /;/, $leftresult;
+ warn " @leftresult / $rightresult \n" if $DEBUG;
+
+ # my @rightresult = split /;/,$leftresult;
+ my $finalresult;
+
+# parse the left results, and if the biblionumber exist in the right result, save it in finalresult
+# the result is stored twice, to have the same weight for AND than OR.
+# example : TWO : 61,61,64,121 (two is twice in the biblio #61) / TOWER : 61,64,130
+# result : 61,61,61,61,64,64 for two AND tower : 61 has more weight than 64
+ foreach (@leftresult) {
+ my $value = $_;
+ my $countvalue;
+ ( $value, $countvalue ) = ( $1, $2 )
+ if $value =~ m/(.*)-(\d+)$/;
+ if ( $rightresult =~ /$value-(\d+);/ ) {
+ $countvalue = ( $1 > $countvalue ? $countvalue : $1 );
+ $finalresult .=
+ "$value-$countvalue;$value-$countvalue;";
+ }