From 05ba7ca4b68947b88894b68a86573b96afbdf1f9 Mon Sep 17 00:00:00 2001 From: Joshua Ferraro Date: Fri, 9 Nov 2007 16:58:44 -0600 Subject: [PATCH] fixing advanced search Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Search.pm | 28 +++++++++++-------- .../prog/en/modules/catalogue/advsearch.tmpl | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 907e410db8..9d506bd650 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -687,12 +687,14 @@ sub _build_weighted_query { #$weighted_query .= " or kw,wrd,r5=$operand"; # index as exact #} else { - $weighted_query .=" $index,ext,r1=$operand"; # index label as exact + warn "WEIGHT GENERIC"; + $weighted_query .=" $index=$operand"; + #$weighted_query .=" $index,ext,r1=$operand"; # index label as exact #$weighted_query .= " or $index,ext,r2=$operand"; # index as exact - $weighted_query .=" or $index,phr,r3=$operand"; # index as phrase - $weighted_query .= " or $index,rt,wrd,r3=$operand"; - $weighted_query .=" or $index,wrd,r5=$operand"; # index as word right-truncated - $weighted_query .= " or $index,wrd,fuzzy,r8=$operand" if $fuzzy_enabled; + #$weighted_query .=" or $index,phr,r3=$operand"; # index as phrase + #$weighted_query .= " or $index,rt,wrd,r3=$operand"; + #$weighted_query .=" or $index,wrd,r5=$operand"; # index as word right-truncated + #$weighted_query .= " or $index,wrd,fuzzy,r8=$operand" if $fuzzy_enabled; } $weighted_query .= "))"; # close rank specification return $weighted_query; @@ -749,17 +751,18 @@ sub buildQuery { if ( $operands[$i] ) { my $operand = $operands[$i]; my $index = $indexes[$i]; + # if there's no index, don't use one, it will throw a CCL error - my $index_plus; $index_plus = "$index:" if $index; - my $index_plus_comma; $index_plus_comma="$index," if $index; + my $index_plus;# $index_plus = "$index:" if $index; + my $index_plus_comma;# $index_plus_comma="$index," if $index; # Remove Stopwords $operand = _remove_stopwords($operand,$index); - + #warn "OP_SW: $operand"; # Handle Truncation my ($nontruncated,$righttruncated,$lefttruncated,$rightlefttruncated,$regexpr); ($nontruncated,$righttruncated,$lefttruncated,$rightlefttruncated,$regexpr) = _add_truncation($operand,$index); - warn "TRUNCATION: NON:@$nontruncated RIGHT:@$righttruncated LEFT:@$lefttruncated RIGHTLEFT:@$rightlefttruncated REGEX:@$regexpr"; + #warn "TRUNCATION: NON:@$nontruncated RIGHT:@$righttruncated LEFT:@$lefttruncated RIGHTLEFT:@$rightlefttruncated REGEX:@$regexpr"; # Handle Stemming my $stemmed_operand; @@ -775,7 +778,8 @@ sub buildQuery { # If there's a previous operand, we need to add an operator if ($previous_operand) { - if ( $operators[ $i - 1 ] ) { + # user-specified operator + if ( $operators[$i-1] ) { $human_search_desc .=" $operators[$i-1] $index_plus $operands[$i]"; $query .= " $operators[$i-1] $index_plus $operand"; } @@ -812,7 +816,7 @@ sub buildQuery { } #/if $operands } # /for } - + #warn "QUERY:".$query; # add limits my $limit_query; my $limit_search_desc; @@ -1173,7 +1177,7 @@ sub NZgetRecords { sub NZanalyse { my ($string,$server) = @_; # $server contains biblioserver or authorities, depending on what we search on. - warn "querying : $string on $server"; + #warn "querying : $string on $server"; $server='biblioserver' unless $server; # if we have a ", replace the content to discard temporarily any and/or/not inside my $commacontent; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl index 8079ad15c8..eefe974032 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tmpl @@ -64,7 +64,7 @@