koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 SearchMarc.pm,1.19,1.20


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/C4 SearchMarc.pm,1.19,1.20
Date: Tue, 22 Jun 2004 01:39:25 -0700

Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21477/C4

Modified Files:
        SearchMarc.pm 
Log Message:
changes in search method :
- supporting * and % on words (* is replaced by %)
- removing % when the word is 3 or less letters

Index: SearchMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/SearchMarc.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** SearchMarc.pm       17 Jun 2004 08:17:01 -0000      1.19
--- SearchMarc.pm       22 Jun 2004 08:39:22 -0000      1.20
***************
*** 121,124 ****
--- 121,126 ----
        for(my $i = 0 ; $i <= $#{$value} ; $i++)
        {
+               # replace * by %
+               @$value[$i] =~ s/\*/%/g;
                if(@$excluding[$i])     # NOT statements
                {
***************
*** 128,131 ****
--- 130,136 ----
                                foreach my $word (split(/ /, @$value[$i]))      
# if operator is contains, splits the words in separate requests
                                {
+                                       # remove the "%" for small word (3 
letters. (note : the >4 is due to the % at the end)
+                                       warn "word : $word";
+                                       $word =~ s/%//g unless length($word)>4;
                                        unless 
(C4::Context->stopwords->{uc($word)}) {  #it's NOT a stopword => use it. 
Otherwise, ignore
                                                push @not_tags, @$tags[$i];
***************
*** 150,153 ****
--- 155,161 ----
                                foreach my $word (split(/ /, @$value[$i]))
                                {
+                                       # remove the "%" for small word (3 
letters. (note : the >4 is due to the % at the end)
+                                       warn "word : $word";
+                                       $word =~ s/%//g unless length($word)>4;
                                        unless 
(C4::Context->stopwords->{uc($word)}) {  #it's NOT a stopword => use it. 
Otherwise, ignore
                                                my $tag = 
substr(@$tags[$i],0,3);
***************
*** 301,305 ****
        my $sql_where1; # will contain the "true" where
        my $sql_where2 = "("; # will contain m1.bibid=m2.bibid
!       my $nb_active=0; # will contain the number of "active" entries. and 
entry is active is a value is provided.
        my $nb_table=1; # will contain the number of table. ++ on each entry 
EXCEPT when an OR  is provided.
  
--- 309,313 ----
        my $sql_where1; # will contain the "true" where
        my $sql_where2 = "("; # will contain m1.bibid=m2.bibid
!       my $nb_active=0; # will contain the number of "active" entries. an 
entry is active if a value is provided.
        my $nb_table=1; # will contain the number of table. ++ on each entry 
EXCEPT when an OR  is provided.
  
***************
*** 310,314 ****
                                if (@$operator[$i] eq "start") {
                                        $sql_tables .= "marc_subfield_table as 
m$nb_table,";
!                                       $sql_where1 .= "(m1.subfieldvalue like 
".$dbh->quote("@$value[$i]%");
                                        if (@$tags[$i]) {
                                                $sql_where1 .=" and 
m1.tag+m1.subfieldcode in (@$tags[$i])";
--- 318,322 ----
                                if (@$operator[$i] eq "start") {
                                        $sql_tables .= "marc_subfield_table as 
m$nb_table,";
!                                       $sql_where1 .= "(m1.subfieldvalue like 
".$dbh->quote("@$value[$i]");
                                        if (@$tags[$i]) {
                                                $sql_where1 .=" and 
m1.tag+m1.subfieldcode in (@$tags[$i])";
***************
*** 317,321 ****
                                } elsif (@$operator[$i] eq "contains") {
                                        $sql_tables .= "marc_word as 
m$nb_table,";
!                                       $sql_where1 .= "(m1.word  like 
".$dbh->quote("@$value[$i]%");
                                        if (@$tags[$i]) {
                                                 $sql_where1 .=" and 
m1.tagsubfield in (@$tags[$i])";
--- 325,329 ----
                                } elsif (@$operator[$i] eq "contains") {
                                        $sql_tables .= "marc_word as 
m$nb_table,";
!                                       $sql_where1 .= "(m1.word  like 
".$dbh->quote("@$value[$i]");
                                        if (@$tags[$i]) {
                                                 $sql_where1 .=" and 
m1.tagsubfield in (@$tags[$i])";
***************
*** 334,338 ****
                                        $nb_table++;
                                        $sql_tables .= "marc_subfield_table as 
m$nb_table,";
!                                       $sql_where1 .= "@$and_or[$i] 
(m$nb_table.subfieldvalue like ".$dbh->quote("@$value[$i]%");
                                        if (@$tags[$i]) {
                                                $sql_where1 .=" and 
m$nb_table.tag+m$nb_table.subfieldcode in (@$tags[$i])";
--- 342,346 ----
                                        $nb_table++;
                                        $sql_tables .= "marc_subfield_table as 
m$nb_table,";
!                                       $sql_where1 .= "@$and_or[$i] 
(m$nb_table.subfieldvalue like ".$dbh->quote("@$value[$i]");
                                        if (@$tags[$i]) {
                                                $sql_where1 .=" and 
m$nb_table.tag+m$nb_table.subfieldcode in (@$tags[$i])";
***************
*** 344,348 ****
                                                $nb_table++;
                                                $sql_tables .= "marc_word as 
m$nb_table,";
!                                               $sql_where1 .= "@$and_or[$i] 
(m$nb_table.word like ".$dbh->quote("@$value[$i]%");
                                                if (@$tags[$i]) {
                                                        $sql_where1 .=" and 
m$nb_table.tagsubfield in(@$tags[$i])";
--- 352,356 ----
                                                $nb_table++;
                                                $sql_tables .= "marc_word as 
m$nb_table,";
!                                               $sql_where1 .= "@$and_or[$i] 
(m$nb_table.word like ".$dbh->quote("@$value[$i]");
                                                if (@$tags[$i]) {
                                                        $sql_where1 .=" and 
m$nb_table.tagsubfield in(@$tags[$i])";
***************
*** 351,355 ****
                                                $sql_where2 .= 
"m1.bibid=m$nb_table.bibid and ";
                                        } else {
!                                               $sql_where1 .= "@$and_or[$i] 
(m$nb_table.word like ".$dbh->quote("@$value[$i]%");
                                                if (@$tags[$i]) {
                                                        $sql_where1 .="  and 
m$nb_table.tagsubfield in (@$tags[$i])";
--- 359,363 ----
                                                $sql_where2 .= 
"m1.bibid=m$nb_table.bibid and ";
                                        } else {
!                                               $sql_where1 .= "@$and_or[$i] 
(m$nb_table.word like ".$dbh->quote("@$value[$i]");
                                                if (@$tags[$i]) {
                                                        $sql_where1 .="  and 
m$nb_table.tagsubfield in (@$tags[$i])";




reply via email to

[Prev in Thread] Current Thread [Next in Thread]