From: mike Date: Fri, 17 Aug 2007 09:38:13 +0000 (+0000) Subject: Add -q option to scan using a CQL query instead of PQF. X-Git-Tag: cpan_1_22~43 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=9c7fc7a5f2424db4a5e2f770862de63376167171;p=ZOOM-Perl-moved-to-github.git Add -q option to scan using a CQL query instead of PQF. Add comments showing use of Z39.50/SRUand Type-1/CQL. (Of course, the combination CQL-over-Z39.50 doesn't work.) --- diff --git a/samples/zoom/zoomscan.pl b/samples/zoom/zoomscan.pl index cf787fa..e73e0c0 100644 --- a/samples/zoom/zoomscan.pl +++ b/samples/zoom/zoomscan.pl @@ -1,24 +1,35 @@ -# $Id: zoomscan.pl,v 1.2 2007-08-16 16:21:08 mike Exp $ +# $Id: zoomscan.pl,v 1.3 2007-08-17 09:38:13 mike Exp $ # # This is the scanning counterpart to zoomscan.pl's searching # perl -I../../blib/lib -I../../blib/arch zoomscan.pl +# +# For example (using Z39.50 and SRW, Type-1 and CQL): +# perl zoomscan.pl tcp:localhost:8018/IR-Explain---1 '@attr 1=dc.title the' +# perl zoomscan.pl http://localhost:8018/IR-Explain---1 '@attr 1=dc.title the' +# perl zoomscan.pl -q http://localhost:8018/IR-Explain---1 'dc.title=the' use strict; use warnings; +use Getopt::Std; use ZOOM; -if (@ARGV != 2) { - print STDERR "Usage: $0 target scanQuery\n"; - print STDERR " eg. $0 z3950.indexdata.dk/gils computer\n"; +my %opts; +if (!getopts('q', \%opts) || @ARGV != 2) { + print STDERR "Usage: $0 [options] target scanQuery + -q Query is CQL [default: PQF] + eg. $0 z3950.indexdata.dk/gils computer\n"; exit 1; } + my($host, $scanQuery) = @ARGV; eval { my $conn = new ZOOM::Connection($host, 0); $conn->option(preferredRecordSyntax => "usmarc"); ### Could use ZOOM::Query::CQL below, but that only work in SRU/W. - my $ss = $conn->scan(new ZOOM::Query::PQF($scanQuery)); + my $q = $opts{q} ? new ZOOM::Query::CQL($scanQuery) : + new ZOOM::Query::PQF($scanQuery); + my $ss = $conn->scan($q); my $n = $ss->size(); for my $i (0..$n-1) { my($term, $occ) = $ss->term($i);