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

Re: [ic] swish search - quotes


Quoting Dan Bergan <suppressed>:

I use swish-e to search my site.  I would like to allow customers to
use all the features they are accustomed to using with search engines.
 In my testing, it looks like quotes are removed from the search  spec,
so a phrase search is impossible.

Is there any way to do a phrase search with swish-e and interchange?
I can do a phrase search from the command line -- the swish-e search
command is:
swish-e -w \"word1 word2\" -f /path/to/index


I've been wading through Swish.pm and Search.pm... It appears that if I set either mv_exact_match or mv_coordinate, spec_check will allow my quotes to pass through:
if ( ! $s->{mv_exact_match} and ! $s->{mv_coordinate}) {
	my $string = join ' ', @specs;
	eval {
		@specs = Text::ParseWords::shellwords( $string );
	};
	if($@ or ! @specs) {
		$string =~ s/['"]/./g;
		$s->{mv_all_chars}[0] = 0;
		@specs = Text::ParseWords::shellwords( $string );
	}
}

However it looks like I will have to do some hacking in Swish.pm it looks like quotes are always removed as "unsafe charachers":
$spec =~ s/[^-\w()"\s\*]+//g
	and $CGI::values{debug}
	and ::logError("Removed unsafe characters from search string");

(My regex skills may be a bit rusty, so please correct me if I'm reading either of these wrong!)

Does this seem like a reasonable thing for me to do in Swish.pm:
#removed quote char (") from regex
$spec =~ s/[^-\w()\s\*]+//g
	and $CGI::values{debug}
	and ::logError("Removed unsafe characters from search string");

if ( $s->{mv_exact_match} ) {
        $spec =~ s/"/\"/g;
}
else {
        $spec =~ s/"//g;
}

I'm getting a bit out of my element here, I would rather not have to change a core file, so I would appreciate any easier ways to accomplish this!

Dan





_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.