Comment on use of PQF instead of CQL
[ZOOM-Perl-moved-to-github.git] / samples / zoom / zoomscan.pl
1 # $Id: zoomscan.pl,v 1.2 2007-08-16 16:21:08 mike Exp $
2 #
3 # This is the scanning counterpart to zoomscan.pl's searching
4 # perl -I../../blib/lib -I../../blib/arch zoomscan.pl <target> <scanQuery>
5
6 use strict;
7 use warnings;
8 use ZOOM;
9
10 if (@ARGV != 2) {
11     print STDERR "Usage: $0 target scanQuery\n";
12     print STDERR "      eg. $0 z3950.indexdata.dk/gils computer\n";
13     exit 1;
14 }
15 my($host, $scanQuery) = @ARGV;
16
17 eval {
18     my $conn = new ZOOM::Connection($host, 0);
19     $conn->option(preferredRecordSyntax => "usmarc");
20     ### Could use ZOOM::Query::CQL below, but that only work in SRU/W.
21     my $ss = $conn->scan(new ZOOM::Query::PQF($scanQuery));
22     my $n = $ss->size();
23     for my $i (0..$n-1) {
24         my($term, $occ) = $ss->term($i);
25         print $i+1, ": $term";
26         print " ($occ)" if defined $occ;
27         print "\n";
28     }
29     
30     $ss->destroy();
31     $conn->destroy();
32 }; if ($@) {
33     die "Non-ZOOM error: $@" if !$@->isa("ZOOM::Exception");
34     print STDERR "ZOOM error $@\n";
35     exit 1;
36 }