2 # =============================================================================
3 # $Id: 05_search.t,v 1.5 2004-09-15 14:11:06 heikki Exp $
6 # =============================================================================
11 push (@INC,'demo','blib/lib','blib/arch');
17 use Test::More tests => 7;
19 # ----------------------------------------------------------------------------
23 IDZebra::logFile("test05.log");
24 use_ok('IDZebra::Session');
29 # ----------------------------------------------------------------------------
30 # Session opening and closing
31 my $sess = IDZebra::Session->open(configFile => 'demo/zebra.cfg',
32 groupName => 'demo2');
33 isa_ok($sess,"IDZebra::Session");
35 # Insert some test data
40 $sess->databases('demo1', 'demo2');
42 for $F (<"lib/IDZebra/*.pm">)
44 ($ret,$sysno)=$sess->insert_record (file=>$F, recordType => 'grs.perl.pod');
45 ok( $ret==0, "inserted $F");
48 # ----------------------------------------------------------------------------
51 my ($hits, $expected);
54 my $rs1 = $sess->search(cqlmap => 'demo/cql.map',
57 databases => [qw(demo1)]);
59 $expected = $filecount;
61 ok(($hits == $expected), "CQL search - found $hits/$expected records");
64 $sess->databases('demo1', 'demo2');
65 my @dblist = $sess->databases;
66 ok(($#dblist == 1), "Select multiple databases");
70 my $rs2 = $sess->search(cqlmap => 'demo/cql.map',
72 $expected = $filecount * 2;
74 ok(($hits == $expected), "CQL search - found $hits/$expected records");
77 my $rs3 = $sess->search(cqlmap => 'demo/cql.map',
78 pqf => '@attr 1=4 IDZebra');
79 $expected = $filecount * 2;
81 ok(($hits == $expected), "RPN search - found $hits/$expected records");
83 #### Terms is broken time being, don't bother testing it
85 #my $rs4 = $sess->search(pqf => '@attr 1=4 @and IDZebra Session');
88 #ok(($hits == $expected), "RPN search - found $hits/$expected records");
89 #print STDERR "Test 8: found $hits of $expected\n";
91 #my @terms = $rs4->terms();
92 #ok(($#terms == 1), "Got 2 terms in RPN expression");
94 #foreach my $t (@terms) {
95 # if ($t->{term} eq 'IDZebra') {
96 # ok(($t->{count} = $filecount*2), "Term IDZebra ($t->{count})");
99 # elsif ($t->{term} eq 'Session') {
100 # ok(($t->{count} = 2), "Term Session ($t->{count})");
103 # ok(0,"Invalid term $t->{term}");
107 #ok (($cc == 2), "Got 2 terms for RS");
111 # More specific search
114 # ----------------------------------------------------------------------------