[interchange-cvs] interchange - heins modified 5 files
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Tue Jun 11 00:51:01 2002
User: heins
Date: 2002-06-11 04:50:23 GMT
Modified: lib/Vend DbSearch.pm Scan.pm Search.pm TextSearch.pm
Added: lib/Vend RefSearch.pm
Log:
* Add new mv_next_search, which allows filtering searches
through another search after the first one returns
some rows.
* Add search_reference() method to Search.pm
* Add st=ref to allow searching of an array of arrays with
an IC search -- I would not think it too useful but this
type of thing has been requested
* New Vend::RefSearch actually does the search
* Search is passed by setting in a scratch variable right now,
suggestions on how to better pass it are appreciated
* A small test will be posted to core list.
Revision Changes Path
2.9 +8 -2 interchange/lib/Vend/DbSearch.pm
rev 2.9, prev_rev 2.8
Index: DbSearch.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/DbSearch.pm,v
retrieving revision 2.8
retrieving revision 2.9
diff -u -r2.8 -r2.9
--- DbSearch.pm 3 Feb 2002 07:11:09 -0000 2.8
+++ DbSearch.pm 11 Jun 2002 04:50:23 -0000 2.9
@@ -1,6 +1,6 @@
# Vend::DbSearch - Search indexes with Interchange
#
-# $Id: DbSearch.pm,v 2.8 2002/02/03 07:11:09 mheins Exp $
+# $Id: DbSearch.pm,v 2.9 2002/06/11 04:50:23 mheins Exp $
#
# Adapted for use with Interchange from Search::TextSearch
#
@@ -26,7 +26,7 @@
@ISA = qw(Vend::Search);
-$VERSION = substr(q$Revision: 2.8 $, 10);
+$VERSION = substr(q$Revision: 2.9 $, 10);
use Search::Dict;
use strict;
@@ -289,6 +289,12 @@
}
}
$s->restore_specs();
+ }
+
+ # Search the results and return
+ if($s->{mv_next_search}) {
+ @out = $s->search_reference(\@out);
+#::logDebug("did next_search: " . ::uneval(\@out));
}
$s->{matches} = scalar(@out);
2.8 +12 -2 interchange/lib/Vend/Scan.pm
rev 2.8, prev_rev 2.7
Index: Scan.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Scan.pm,v
retrieving revision 2.7
retrieving revision 2.8
diff -u -r2.7 -r2.8
--- Scan.pm 31 Jan 2002 17:32:31 -0000 2.7
+++ Scan.pm 11 Jun 2002 04:50:23 -0000 2.8
@@ -1,6 +1,6 @@
# Vend::Scan - Prepare searches for Interchange
#
-# $Id: Scan.pm,v 2.7 2002/01/31 17:32:31 mheins Exp $
+# $Id: Scan.pm,v 2.8 2002/06/11 04:50:23 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -29,12 +29,15 @@
perform_search
);
-$VERSION = substr(q$Revision: 2.7 $, 10);
+$VERSION = substr(q$Revision: 2.8 $, 10);
use strict;
use Vend::Util;
use Vend::Interpolate;
use Vend::Data qw(product_code_exists_ref column_index);
+use Vend::TextSearch;
+use Vend::DbSearch;
+use Vend::RefSearch;
my @Order = ( qw(
mv_dict_look
@@ -99,6 +102,8 @@
mv_unique
mv_more_matches
mv_value
+ mv_next_search
+ mv_search_reference
prefix
));
@@ -142,12 +147,14 @@
ne mv_negate
ng mv_negate
np mv_nextpage
+ ns mv_next_search
nu mv_numeric
op mv_column_op
os mv_orsearch
pf prefix
ra mv_return_all
rd mv_return_delim
+ re mv_search_reference
rf mv_return_fields
rg mv_range_alpha
rl mv_range_look
@@ -491,6 +498,9 @@
}
elsif (! $options{mv_searchtype} or $options{mv_searchtype} eq 'text') {
$q = new Vend::TextSearch %options;
+ }
+ elsif ( $options{mv_searchtype} eq 'ref'){
+ $q = new Vend::RefSearch %options;
}
# GLIMPSE
elsif ( $options{mv_searchtype} eq 'glimpse'){
2.7 +27 -7 interchange/lib/Vend/Search.pm
rev 2.7, prev_rev 2.6
Index: Search.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Search.pm,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -r2.6 -r2.7
--- Search.pm 28 Feb 2002 17:32:15 -0000 2.6
+++ Search.pm 11 Jun 2002 04:50:23 -0000 2.7
@@ -1,6 +1,6 @@
# Vend::Search - Base class for search engines
#
-# $Id: Search.pm,v 2.6 2002/02/28 17:32:15 jon Exp $
+# $Id: Search.pm,v 2.7 2002/06/11 04:50:23 mheins Exp $
#
# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
@@ -21,7 +21,7 @@
package Vend::Search;
-$VERSION = substr(q$Revision: 2.6 $, 10);
+$VERSION = substr(q$Revision: 2.7 $, 10);
use strict;
use vars qw($VERSION);
@@ -91,6 +91,25 @@
my (@hashable) = (qw/mv_return_fields mv_range_look mv_search_field mv_sort_field/);
+sub search_reference {
+ my ($s, $ref) = @_;
+ my $c = { mv_searchtype => 'ref', label => ref($s), mv_search_file => '__none__' };
+
+ my $ns = $s->{mv_next_search};
+ $ns = $::Scratch->{$ns} unless $ns =~ /=/;
+ my $params = Vend::Interpolate::escape_scan($ns);
+#::logDebug("search_params: $params");
+ Vend::Scan::find_search_params($c, $params);
+
+ $c->{mv_return_filtered} = 1;
+ $c->{mv_return_fields} = '*';
+ $c->{mv_field_names} = $s->{mv_field_names};
+ $c->{mv_search_reference} = $ref;
+#::logDebug("Ref ready to search: " . ::uneval($c));
+ my $o = Vend::Scan::perform_search($c);
+ return @{$o->{mv_results} || []};
+}
+
sub hash_fields {
my ($s, $fn, @laundry) = @_;
my %fh;
@@ -421,7 +440,7 @@
# We will pick out the return fields later if sorting
# This returns
- if( $s->{mv_sort_field} ) {
+ if( $s->{mv_sort_field} || $s->{mv_next_search}) {
return (
sub {
[ split /$delim/o, shift(@_) ]
@@ -445,7 +464,7 @@
else {
# We will pick out the return fields later if sorting
# This returns
- if(! $final and $s->{mv_sort_field}) {
+ if(! $final and $s->{mv_sort_field} || $s->{mv_next_search}) {
return ( sub { [ @{ shift(@_) } ] }, 1);
}
@@ -991,11 +1010,12 @@
}
sub search_error {
- my ($s, $msg) = @_;
+ my ($s, $msg, @args) = @_;
$s->{mv_search_error} = [] if ! $s->{mv_search_error};
+ $msg = ::errmsg($msg, @args);
push @{$s->{mv_search_error}}, $msg;
$s->{matches} = -1;
- ::logError ("search error: $msg");
+ ::logError ("search error: %s", $msg);
return undef;
}
@@ -1053,7 +1073,7 @@
sub sort_search_return {
my ($s, $target) = @_;
- @Flds = @{$s->{mv_sort_field}};
+ @Flds = @{$s->{mv_sort_field} || []};
for(@Flds) {
next if /^\d+$/;
$_ = $s->{field_hash}{$_}
2.5 +11 -4 interchange/lib/Vend/TextSearch.pm
rev 2.5, prev_rev 2.4
Index: TextSearch.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/TextSearch.pm,v
retrieving revision 2.4
retrieving revision 2.5
diff -u -r2.4 -r2.5
--- TextSearch.pm 1 Feb 2002 03:20:10 -0000 2.4
+++ TextSearch.pm 11 Jun 2002 04:50:23 -0000 2.5
@@ -1,6 +1,6 @@
# Vend::TextSearch - Search indexes with Perl
#
-# $Id: TextSearch.pm,v 2.4 2002/02/01 03:20:10 mheins Exp $
+# $Id: TextSearch.pm,v 2.5 2002/06/11 04:50:23 mheins Exp $
#
# Adapted for use with Interchange from Search::TextSearch
#
@@ -28,7 +28,7 @@
use vars qw(@ISA);
@ISA = qw(Vend::Search);
-$VERSION = substr(q$Revision: 2.4 $, 10);
+$VERSION = substr(q$Revision: 2.5 $, 10);
use Search::Dict;
use strict;
@@ -313,10 +313,17 @@
$s->restore_specs();
}
- $s->{matches} = scalar(@out);
-
#::logDebug("before delayed return: self=" . ::Vend::Util::uneval_it({%$s}));
#::logDebug("before delayed return: out=" . ::Vend::Util::uneval_it(\@out));
+
+ # Search the results and return
+ if($s->{mv_next_search}) {
+ @out = $s->search_reference(\@out);
+#::logDebug("did next_search: " . ::uneval(\@out));
+ }
+
+ $s->{matches} = scalar(@out);
+
if($delayed_return and $s->{matches} > 0) {
$s->hash_fields($s->{mv_field_names}, qw/mv_sort_field/);
#::logDebug("after hash fields: self=" . ::Vend::Util::uneval_it({%$s}));
2.1 interchange/lib/Vend/RefSearch.pm
rev 2.1, prev_rev 2.0