summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
bb916bf)
- if the user search on >= or <=, fix a bug removing the < and >
- if the user search on a numeric value (mainly for dates search), retrieve only numeric results
Example : previously Date >=2005 returned "printed in 1976", as "printed" was > than 2005
now it don't.
note that Date >=1900 returns "printed in 1976" as NZ search is a always wrdl search (and, as you know 1976 > 1900 ;-) )
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
$string =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|&|\+|\*|\// /g;
# warn "leaf : $string\n";
# parse the string in in operator/operand/value again
$string =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|&|\+|\*|\// /g;
# warn "leaf : $string\n";
# parse the string in in operator/operand/value again
- $string =~ /(.*)(=|>|>=|<|<=)(.*)/;
+ $string =~ /(.*)(>=|<=)(.*)/;
my $left = $1;
my $operator = $2;
my $right = $3;
my $left = $1;
my $operator = $2;
my $right = $3;
+ unless ($operator) {
+ $string =~ /(.*)(>|<|=)(.*)/;
+ $left = $1;
+ $operator = $2;
+ $right = $3;
+ }
my $results;
# automatic replace for short operators
$left='title' if $left =~ '^ti';
my $results;
# automatic replace for short operators
$left='title' if $left =~ '^ti';
#do a specific search
my $dbh = C4::Context->dbh;
$operator='LIKE' if $operator eq '=' and $right=~ /%/;
#do a specific search
my $dbh = C4::Context->dbh;
$operator='LIKE' if $operator eq '=' and $right=~ /%/;
- my $sth = $dbh->prepare("SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value $operator ?");
- # warn "$left / $operator / $right\n";
+ my $sth = $dbh->prepare("SELECT biblionumbers,value FROM nozebra WHERE server=? AND indexname=? AND value $operator ?");
+ warn "$left / $operator / $right\n";
# split each word, query the DB and build the biblionumbers result
foreach (split / /,$right) {
# split each word, query the DB and build the biblionumbers result
foreach (split / /,$right) {
+ my ($biblionumbers,$value);
-# warn "EXECUTE : $server, $left, $_";
+ warn "EXECUTE : $server, $left, $_";
$sth->execute($server, $left, $_);
$sth->execute($server, $left, $_);
- while (my $line = $sth->fetchrow) {
- $biblionumbers .= $line;
-# warn "result : $line";
+ while (my ($line,$value) = $sth->fetchrow) {
+ # if we are dealing with a numeric value, use only numeric results (in case of >=, <=, > or <)
+ # otherwise, fill the result
+ $biblionumbers .= $line unless ($right =~ /\d/ && $value =~ /\D/);
+ warn "result : $value ". ($right =~ /\d/) . "==".(!$value =~ /\d/) ;#= $line";
}
# do a AND with existing list if there is one, otherwise, use the biblionumbers list as 1st result list
if ($results) {
}
# do a AND with existing list if there is one, otherwise, use the biblionumbers list as 1st result list
if ($results) {