From 8a636819bbdf33b6f365c4919fdeacc2f5874aef Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Mon, 16 Jan 2012 11:40:12 -0500 Subject: [PATCH] in autosuggest.pm, this is how we prepare a suggest search string for tsquery Signed-off-by: Lebbeous Fogle-Weekley --- Open-ILS/src/perlmods/lib/OpenILS/WWW/AutoSuggest.pm | 9 +++++++++ 1 file changed, 9 insertions(+) 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; -- 2.11.0