From: senator Date: Mon, 28 Feb 2011 13:36:43 +0000 (-0500) Subject: Implement mike's suggestions from #esi-dev on 27 Feb 2011 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=0b77572d8dcca3f2d4a08480bcc850430f755d93;p=evergreen%2Fequinox.git Implement mike's suggestions from #esi-dev on 27 Feb 2011 This makes an "exact" search build a query with starting and ending anchors, and adds a new contains-value called "phrase" which does what "exact" was doing before. --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index e4b0741dbf..e2ea613a37 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -30,9 +30,12 @@ sub _prepare_biblio_search_basics { $query =~ s/"//g; $query = ('"' . $query . '"') if index $query, ' '; $query = '-' . $query; - } elsif ($contains eq 'exact') { + } elsif ($contains eq 'phrase') { $query =~ s/"//g; $query = ('"' . $query . '"') if index $query, ' '; + } elsif ($contains eq 'exact') { + $query =~ s/[\^\$]//g; + $query = '^' . $query . '$'; } push @chunks, $query; } @@ -103,24 +106,10 @@ sub load_rresults { my $offset = $page * $limit; my $query = _prepare_biblio_search($cgi, $ctx); -# XXX for now, we still put limit and offset into a hash rather than -# right into the query string, because use of the limit() and offset() filters -# in the query string doesn't actually work as advertised. -# -# When you do, with offsets > 0, you get wrong results in the 'count' -# part of the result hash from open-ils.search.biblio.multiclass.query. -# -# if (defined $cgi->param('limit') or not $query =~ /limit\(\d+\)/) { -# $query =~ s/ limit\(\d+\)//; -# $query .= " limit($limit)"; -# } -# if (defined $cgi->param('page') or not $query =~ /offset\(\d+\)/) { -# $query =~ s/ offset\(\d+\)//; -# $query .= " offset($offset)"; -# } + # Limit and offset will stay here. Everything else should be part of + # the query string, not special args. my $args = {'limit' => $limit, 'offset' => $offset}; - # Stuff these into the TT context so that templates can use them in redrawing forms $ctx->{processed_search_query} = $query; diff --git a/Open-ILS/web/templates/default/opac/parts/advanced/global_row.tt2 b/Open-ILS/web/templates/default/opac/parts/advanced/global_row.tt2 index 2f874c92ce..ae8081e069 100644 --- a/Open-ILS/web/templates/default/opac/parts/advanced/global_row.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/advanced/global_row.tt2 @@ -1,4 +1,10 @@ [% + contains_options = [ + {value => 'contains', label => l('Contains')}, + {value => 'nocontains', label => l('Does not contain')}, + {value => 'phrase', label => l('Contains phrase')}, + {value => 'exact', label => l('Matches exactly')} + ]; contains = CGI.param('contains'); queries = CGI.param('query'); qtypes = CGI.param('qtype') || ['keyword' x 3]; @@ -12,9 +18,10 @@ query_type=qtype %]