From: Lebbeous Fogle-Weekley Date: Mon, 16 Jan 2012 16:40:12 +0000 (-0500) Subject: in autosuggest.pm, this is how we prepare a suggest search string for tsquery X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=8a636819bbdf33b6f365c4919fdeacc2f5874aef;p=evergreen%2Fequinox.git in autosuggest.pm, this is how we prepare a suggest search string for tsquery Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AutoSuggest.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AutoSuggest.pm index 11164379ec..31110690e9 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AutoSuggest.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AutoSuggest.pm @@ -12,6 +12,15 @@ use Apache2::RequestUtil; use CGI; +sub prepare_for_tsquery { + my ($str) = shift; + + $str =~ s/[^\w\s]/ /ig; + $str .= ":*" unless $str =~ /\s$/; + + return join(" & ", split(/\s+/, $str)); +} + sub handler { my $r = shift; my $cgi = new CGI;