fixing a bug in searches with stopwords (that where not dropped).
authortipaul <tipaul>
Mon, 24 Nov 2003 16:53:10 +0000 (16:53 +0000)
committertipaul <tipaul>
Mon, 24 Nov 2003 16:53:10 +0000 (16:53 +0000)
Moving "contains" as 1st choice for the search (= default one)

C4/SearchMarc.pm
koha-tmpl/intranet-tmpl/default/en/search.marc/search.tmpl
koha-tmpl/intranet-tmpl/default/fr/search.marc/search.tmpl

index 67d941e..16fe9b6 100644 (file)
@@ -89,11 +89,13 @@ sub catalogsearch {
                        {
                                foreach my $word (split(/ /, @$value[$i]))      # if operator is contains, splits the words in separate requests
                                {
-                                       push @not_tags, @$tags[$i];
-                                       push @not_subfields, @$subfields[$i];
-                                       push @not_and_or, "or"; # as request is negated, finds "foo" or "bar" if final request is NOT "foo" and "bar"
-                                       push @not_operator, @$operator[$i];
-                                       push @not_value, $word;
+                                       unless (C4::Context->stopwords->{uc($word)}) {  #it's NOT a stopword => use it. Otherwise, ignore
+                                               push @not_tags, @$tags[$i];
+                                               push @not_subfields, @$subfields[$i];
+                                               push @not_and_or, "or"; # as request is negated, finds "foo" or "bar" if final request is NOT "foo" and "bar"
+                                               push @not_operator, @$operator[$i];
+                                               push @not_value, $word;
+                                       }
                                }
                        }
                        else
@@ -111,11 +113,13 @@ sub catalogsearch {
                        {
                                foreach my $word (split(/ /, @$value[$i]))
                                {
-                                       push @normal_tags, @$tags[$i];
-                                       push @normal_subfields, @$subfields[$i];
-                                       push @normal_and_or, "and";     # assumes "foo" and "bar" if "foo bar" is entered
-                                       push @normal_operator, @$operator[$i];
-                                       push @normal_value, $word;
+                                       unless (C4::Context->stopwords->{uc($word)}) {  #it's NOT a stopword => use it. Otherwise, ignore
+                                               push @normal_tags, @$tags[$i];
+                                               push @normal_subfields, @$subfields[$i];
+                                               push @normal_and_or, "and";     # assumes "foo" and "bar" if "foo bar" is entered
+                                               push @normal_operator, @$operator[$i];
+                                               push @normal_value, $word;
+                                       }
                                }
                        }
                        else
index df0dfc7..1dbbda1 100644 (file)
@@ -50,9 +50,9 @@
                        </td>
                        <td>
                                <select name="operator" size="1" onchange="sql_update()">
+                                       <option <TMPL_IF NAME="contains">selected</TMPL_IF> value="contains">Contains</option>
                                        <option <TMPL_IF NAME="eq">selected</TMPL_IF> value="=">Is equal to</option>
                                        <option <TMPL_IF NAME="start">selected</TMPL_IF> value="start">Starts with</option>
-                                       <option <TMPL_IF NAME="contains">selected</TMPL_IF> value="contains">Contains</option>
                                        <option <TMPL_IF NAME="gt">selected</TMPL_IF> value=">">Is greater than</option>
                                        <option <TMPL_IF NAME="ge">selected</TMPL_IF> value=">=">Is greater or equal to</option>
                                        <option <TMPL_IF NAME="lt">selected</TMPL_IF> value="<">Is lower than</option>
index e1c3c06..7aa5bde 100644 (file)
@@ -51,9 +51,9 @@
                        </td>
                        <td>
                                <select name="operator" size="1" onchange="sql_update()">
+                                       <option <TMPL_IF NAME="contains">selected</TMPL_IF> value="contains">Contient</option>
                                        <option <TMPL_IF NAME="eq">selected</TMPL_IF> value="=">Egale</option>
                                        <option <TMPL_IF NAME="start">selected</TMPL_IF> value="start">Commence par</option>
-                                       <option <TMPL_IF NAME="contains">selected</TMPL_IF> value="contains">Contient</option>
                                        <option <TMPL_IF NAME="gt">selected</TMPL_IF> value=">">Supérieur à</option>
                                        <option <TMPL_IF NAME="ge">selected</TMPL_IF> value=">=">Supérieur ou égal à</option>
                                        <option <TMPL_IF NAME="lt">selected</TMPL_IF> value="<">Inférieur à</option>