2 # =============================================================================
3 # $Id: 05_search.t,v 1.4 2004-07-28 08:15:47 adam Exp $
6 # =============================================================================
11 push (@INC,'demo','blib/lib','blib/arch');
17 use Test::More tests => 12;
19 # ----------------------------------------------------------------------------
20 # Session opening and closing
24 IDZebra::logFile("test05.log");
25 use_ok('IDZebra::Session');
30 # ----------------------------------------------------------------------------
31 # Session opening and closing
32 my $sess = IDZebra::Session->open(configFile => 'demo/zebra.cfg',
33 groupName => 'demo2');
34 isa_ok($sess,"IDZebra::Session");
36 # ----------------------------------------------------------------------------
40 my ($hits, $expected);
43 my $rs1 = $sess->search(cqlmap => 'demo/cql.map',
46 databases => [qw(demo1)]);
48 $expected = $filecount;
50 ok(($hits == $expected), "CQL search - found $hits/$expected records");
53 $sess->databases('demo1', 'demo2');
54 my @dblist = $sess->databases;
55 ok(($#dblist == 1), "Select multiple databases");
59 my $rs2 = $sess->search(cqlmap => 'demo/cql.map',
61 $expected = $filecount * 2;
63 ok(($hits == $expected), "CQL search - found $hits/$expected records");
66 my $rs3 = $sess->search(cqlmap => 'demo/cql.map',
67 pqf => '@attr 1=4 IDZebra');
68 $expected = $filecount * 2;
70 ok(($hits == $expected), "RPN search - found $hits/$expected records");
73 my $rs4 = $sess->search(pqf => '@attr 1=4 @and IDZebra Session');
76 ok(($hits == $expected), "RPN search - found $hits/$expected records");
78 my @terms = $rs4->terms();
79 ok(($#terms == 1), "Got 2 terms in RPN expression");
81 foreach my $t (@terms) {
82 if ($t->{term} eq 'IDZebra') {
83 ok(($t->{count} = $filecount*2), "Term IDZebra ($t->{count})");
86 elsif ($t->{term} eq 'Session') {
87 ok(($t->{count} = 2), "Term Session ($t->{count})");
90 ok(0,"Invalid term $t->{term}");
94 ok (($cc == 2), "Got 2 terms for RS");
98 # More specific search
101 # ----------------------------------------------------------------------------