int *statuses);
+/* Resultset terms */
+%name(resultSetTerms)
+int zebra_resultSetTerms (ZebraHandle zh, const char *setname,
+ int no, int *REFERENCE,
+ int *REFERENCE, char *out, int *REFERENCE);
+
/* == Sort ================================================================= */
%name(sort)
int zebra_sort_by_specstr (ZebraHandle zh,
* perl5.swg
*
* Perl5 runtime library
- * $Header: /home/cvsroot/idis/perl/Attic/IDZebra_wrap.c,v 1.19 2003-07-07 10:59:33 pop Exp $
+ * $Header: /home/cvsroot/idis/perl/Attic/IDZebra_wrap.c,v 1.20 2003-07-26 16:27:46 pop Exp $
* ----------------------------------------------------------------------------- */
#define SWIGPERL
}
+XS(_wrap_resultSetTerms) {
+ char _swigmsg[SWIG_MAX_ERRMSG] = "";
+ const char *_swigerr = _swigmsg;
+ {
+ ZebraHandle arg1 ;
+ char *arg2 ;
+ int arg3 ;
+ int *arg4 ;
+ int *arg5 ;
+ char *arg6 ;
+ int *arg7 ;
+ int result;
+ int dvalue4 ;
+ int dvalue5 ;
+ int dvalue7 ;
+ int argvi = 0;
+ SV * _saved[3] ;
+ dXSARGS;
+
+ if ((items < 7) || (items > 7)) {
+ SWIG_croak("Usage: resultSetTerms(zh,setname,no,REFERENCE,REFERENCE,out,REFERENCE);");
+ }
+ {
+ ZebraHandle * argp;
+ if (SWIG_ConvertPtr(ST(0),(void **) &argp, SWIGTYPE_p_ZebraHandle,0) < 0) {
+ SWIG_croak("Type error in argument 1 of resultSetTerms. Expected _p_ZebraHandle");
+ }
+ arg1 = *argp;
+ }
+ if (!SvOK((SV*) ST(1))) arg2 = 0;
+ else arg2 = (char *) SvPV(ST(1), PL_na);
+ arg3 = (int) SvIV(ST(2));
+ {
+ SV *tempsv;
+ if (!SvROK(ST(3))) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV(ST(3));
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected a integer reference");
+ }
+ dvalue4 = SvIV(tempsv);
+ arg4 = &dvalue4;
+ }
+ {
+ SV *tempsv;
+ if (!SvROK(ST(4))) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV(ST(4));
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected a integer reference");
+ }
+ dvalue5 = SvIV(tempsv);
+ arg5 = &dvalue5;
+ }
+ if (!SvOK((SV*) ST(5))) arg6 = 0;
+ else arg6 = (char *) SvPV(ST(5), PL_na);
+ {
+ SV *tempsv;
+ if (!SvROK(ST(6))) {
+ SWIG_croak("expected a reference");
+ }
+ tempsv = SvRV(ST(6));
+ if (!SvIOK(tempsv)) {
+ SWIG_croak("expected a integer reference");
+ }
+ dvalue7 = SvIV(tempsv);
+ arg7 = &dvalue7;
+ }
+ _saved[0] = ST(3);
+ _saved[1] = ST(4);
+ _saved[2] = ST(6);
+ result = (int)zebra_resultSetTerms(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7);
+
+ ST(argvi) = sv_newmortal();
+ sv_setiv(ST(argvi++), (IV) result);
+ {
+ SV *tempsv;
+ tempsv = SvRV(_saved[0]);
+ sv_setiv(tempsv, (IV) *arg4);
+ }
+ {
+ SV *tempsv;
+ tempsv = SvRV(_saved[1]);
+ sv_setiv(tempsv, (IV) *arg5);
+ }
+ {
+ SV *tempsv;
+ tempsv = SvRV(_saved[2]);
+ sv_setiv(tempsv, (IV) *arg7);
+ }
+ XSRETURN(argvi);
+ fail:
+ (void) _swigerr;
+ }
+ croak(_swigerr);
+}
+
+
XS(_wrap_sort) {
char _swigmsg[SWIG_MAX_ERRMSG] = "";
const char *_swigerr = _swigmsg;
{"IDZebrac::records_retrieve", _wrap_records_retrieve},
{"IDZebrac::record_retrieve", _wrap_record_retrieve},
{"IDZebrac::deleteResultSet", _wrap_deleteResultSet},
+{"IDZebrac::resultSetTerms", _wrap_resultSetTerms},
{"IDZebrac::sort", _wrap_sort},
{"IDZebrac::scan_PQF", _wrap_scan_PQF},
{"IDZebrac::getScanEntry", _wrap_getScanEntry},
*records_retrieve = *IDZebrac::records_retrieve;
*record_retrieve = *IDZebrac::record_retrieve;
*deleteResultSet = *IDZebrac::deleteResultSet;
+*resultSetTerms = *IDZebrac::resultSetTerms;
*sort = *IDZebrac::sort;
*scan_PQF = *IDZebrac::scan_PQF;
sub getScanEntry {
-# $Id: Resultset.pm,v 1.9 2003-03-06 23:32:10 pop Exp $
+# $Id: Resultset.pm,v 1.10 2003-07-26 16:27:46 pop Exp $
#
# Zebra perl API header
# =============================================================================
use IDZebra::Logger qw(:flags :calls);
use Scalar::Util qw(weaken);
use Carp;
- our $VERSION = do { my @r = (q$Revision: 1.9 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+ our $VERSION = do { my @r = (q$Revision: 1.10 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
our @ISA = qw(IDZebra::Logger);
}
$self->{odr_stream} = IDZebra::odr_createmem($IDZebra::ODR_DECODE);
$self->{name} = $args{name};
+ $self->{query} = $args{query};
$self->{recordCount} = $args{recordCount};
$self->{errCode} = $args{errCode};
$self->{errString} = $args{errString};
return ($self->{errCode});
}
+sub terms {
+ use Data::Dumper;
+ my ($self) = @_;
+ my $count = 0; my $type = 0; my $len = 0;
+ my $tc = IDZebra::resultSetTerms($self->{session}{zh},$self->{name},
+ 0, \$count, \$type, "\0", \$len);
+
+ logf (LOG_LOG,"Got $tc terms");
+
+
+ my @res = ();
+ for (my $i=0; $i<$tc; $i++) {
+ my $len = 1024;
+ my $t = {term => "\0" x $len, count => 0, type => 0};
+ my $stat = IDZebra::resultSetTerms($self->{session}{zh},$self->{name},
+ $i, \$t->{count}, \$t->{type},
+ $t->{term}, \$len);
+ $t->{term} = substr($t->{term}, 0, $len);
+ logf (LOG_LOG,
+ "term $i: type $t->{type}, '$t->{term}' ($t->{count})");
+ push (@res, $t);
+ }
+ return (@res);
+}
+
# =============================================================================
sub DESTROY {
my $self = shift;
-# $Id: Session.pm,v 1.18 2003-07-07 10:59:33 pop Exp $
+# $Id: Session.pm,v 1.19 2003-07-26 16:27:46 pop Exp $
#
# Zebra perl API header
# =============================================================================
use IDZebra::ScanList;
use IDZebra::RetrievalRecord;
require Exporter;
- our $VERSION = do { my @r = (q$Revision: 1.18 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+ our $VERSION = do { my @r = (q$Revision: 1.19 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
our @ISA = qw(IDZebra::Logger Exporter);
our @EXPORT = qw (TRANS_RW TRANS_RO);
}
$self->databases(@{$args{databases}});
}
+
my $rsname = $args{rsname} ? $args{rsname} : $self->_new_setname;
my $rs = $self->_search_pqf($query, $rsname);
my $rs = IDZebra::Resultset->new($self,
name => $setname,
+ query => $query,
recordCount => $hits,
errCode => $self->errCode,
errString => $self->errString);
#!perl
# =============================================================================
-# $Id: 05_search.t,v 1.2 2003-03-04 19:33:53 pop Exp $
+# $Id: 05_search.t,v 1.3 2003-07-26 16:27:46 pop Exp $
#
# Perl API header
# =============================================================================
use strict;
use warnings;
-use Test::More tests => 7;
+use Test::More tests => 12;
# ----------------------------------------------------------------------------
# Session opening and closing
# Search 1 databases
my $rs1 = $sess->search(cqlmap => 'demo/cql.map',
cql => 'IDZebra',
+ termset => 1,
databases => [qw(demo1)]);
$expected = $filecount;
my $rs3 = $sess->search(cqlmap => 'demo/cql.map',
pqf => '@attr 1=4 IDZebra');
$expected = $filecount * 2;
-$hits = $rs2->count;
+$hits = $rs3->count;
+ok(($hits == $expected), "RPN search - found $hits/$expected records");
+
+# Termlists;
+my $rs4 = $sess->search(pqf => '@attr 1=4 @and IDZebra Session');
+$expected = 2;
+$hits = $rs4->count;
ok(($hits == $expected), "RPN search - found $hits/$expected records");
+my @terms = $rs4->terms();
+ok(($#terms == 1), "Got 2 terms in RPN expression");
+my $cc = 0;
+foreach my $t (@terms) {
+ if ($t->{term} eq 'IDZebra') {
+ ok(($t->{count} = $filecount*2), "Term IDZebra ($t->{count})");
+ $cc++;
+ }
+ elsif ($t->{term} eq 'Session') {
+ ok(($t->{count} = 2), "Term Session ($t->{count})");
+ $cc++;
+ } else {
+ ok(0,"Invalid term $t->{term}");
+ }
+
+}
+ok (($cc == 2), "Got 2 terms for RS");
+
+
# More specific search