[interchange-cvs] interchange - racke modified lib/Vend/Swish2.pm
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Fri Jun 23 10:18:23 EDT 2006
User: racke
Date: 2006-06-23 14:18:23 GMT
Modified: lib/Vend Swish2.pm
Log:
check mv_field_names vs available properties to avoid crashes later on
Revision Changes Path
1.4 +31 -2 interchange/lib/Vend/Swish2.pm
rev 1.4, prev_rev 1.3
Index: Swish2.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Swish2.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Swish2.pm 23 Jun 2006 12:31:41 -0000 1.3
+++ Swish2.pm 23 Jun 2006 14:18:23 -0000 1.4
@@ -1,6 +1,6 @@
# Vend::Swish2 - Search indexes with Swish-e's new SWISH::API
#
-# $Id: Swish2.pm,v 1.3 2006/06/23 12:31:41 racke Exp $
+# $Id: Swish2.pm,v 1.4 2006/06/23 14:18:23 racke Exp $
#
# Adapted from Vend::Swish by Brian Miller <brian at endpoint.com>
#
@@ -26,7 +26,7 @@
require Vend::Search;
@ISA = qw(Vend::Search);
-$VERSION = substr(q$Revision: 1.3 $, 10);
+$VERSION = substr(q$Revision: 1.4 $, 10);
use strict;
use lib qw( /usr/local/lib/swish-e/perl );
@@ -183,6 +183,35 @@
}
my $engine = $_swish->{ $s->{'swish_index'} };
+
+ # check properties first
+ my @indexes = $engine->IndexNames();
+ my $index_num = @indexes;
+ my (%prop_avail, @plist, $prop);
+
+ for my $index (@indexes) {
+ @plist = $engine->PropertyList($index);
+ for $prop (@plist) {
+ push (@{$prop_avail{$prop->Name()}}, $index);
+ }
+ }
+
+ for (@{ $s->{'mv_field_names'} }) {
+ if (exists $fmap{$_}) {
+ $prop = $fmap{$_};
+ } else {
+ $prop = $_;
+ }
+
+ unless (exists $prop_avail{$prop}) {
+ return $s->search_error("Unknown property '$prop'");
+ }
+
+ unless (@{$prop_avail{$prop}} == $index_num) {
+ return $s->search_error("Property '$prop' is missing from some index files");
+ }
+ }
+
my $results = $engine->Query( $search_string );
if ($engine->Error) {
More information about the interchange-cvs
mailing list