1 # $Id: Search.pm,v 1.15 2007-05-01 16:30:42 mike Exp $
3 package ZOOM::IRSpy::Task::Search;
10 our @ISA = qw(ZOOM::IRSpy::Task);
14 ZOOM::IRSpy::Task::Search - a searching task for IRSpy
30 die "$class: unrecognised query type '$qtype'"
31 if !grep { $qtype eq $_ } qw(pqf cql);
33 my $this = $class->SUPER::new(@_);
34 $this->{qtype} = $qtype;
35 $this->{qstr} = $qstr;
45 my $conn = $this->conn();
46 $conn->connect($conn->option("host"));
48 my $qtype = $this->{qtype};
49 my $qstr = $this->{qstr};
50 $this->irspy()->log("irspy_task", $conn->option("host"),
51 " searching for '$qtype:$qstr'");
52 die "task $this has resultset?!" if defined $this->{rs};
55 if ($qtype eq "pqf") {
56 $query = new ZOOM::Query::PQF($qstr);
57 } elsif ($qtype eq "cql") {
58 $query = new ZOOM::Query::CQL($qstr);
63 ### Note well that when this task runs, it creates a result-set
64 # object which MUST BE DESTROYED in order to prevent large-scale
65 # memory leakage. So when creating a Task::Search, it is the
66 # APPLICATION'S RESPONSIBILITY to ensure that the callback
67 # invoked on success OR FAILURE makes arrangements for the set
69 $this->{rs} = $conn->search($query);
70 warn "no ZOOM-C level events queued by $this"
76 # Unique to Task::Search, used only for logging
79 return $this->{qtype} . ":" . $this->{qstr}
84 return ref($this) . "(" . $this->render_query() . ")";
87 use overload '""' => \&render;
96 Mike Taylor, E<lt>mike@indexdata.comE<gt>
98 =head1 COPYRIGHT AND LICENSE
100 Copyright (C) 2006 by Index Data ApS.
102 This library is free software; you can redistribute it and/or modify
103 it under the same terms as Perl itself, either Perl version 5.8.7 or,
104 at your option, any later version of Perl 5 you may have available.