[Xapian-discuss] Perl interface isn't working in 1.2.x

Jim Lynch jim at k4gvo.com
Tue Aug 27 17:57:25 BST 2013


On 08/26/2013 04:58 PM, Olly Betts wrote:
> On Mon, Aug 26, 2013 at 08:51:29AM -0400, Jim Lynch wrote:
>> On 08/25/2013 05:02 PM, Olly Betts wrote:
>>> So the simple fix is
>>> probably just to install the perl-Search-Xapian RPM instead.
>> Thanks, the Centos 6 repos don't have that rpm and the
>> http://xapian.org/download page seems to only cover the XS bindings,
> No, it covers both:
>
> | For convenience you can install a package to pull in his package repository
> | and then you can install the packages using yum:
> |
> |    $ su
> |     enter your root password
> |     # rpm -ivh http://rpm.eprints.org/rpm-eprints-org-key-1-1.noarch.rpm
> |     # rpm -ivh http://rpm.eprints.org/xapian/6/noarch/rpm-eprints-org-xapian-6-1.noarch.rpm
> |     # yum update
> |     # yum install xapian-omega xapian-bindings-{php,python,tcl8,perl,ruby}
>
> So this (xapian-bindings-perl) would be the SWIG-based Perl bindings.
>
> | (or whatever Xapian packages you want to install).
> |
> | perl-Search-Xapian is available for those not using the SWIG bindings.
>
> And this is the hand-coded XS bindings.
>
> Cheers,
>      Olly
>
>
I thought I was using the SWIG version, since I had 
rpm-eprints-org-xapian.repo in my yum.repos.d directory.   So I created 
a Centos 6 VM, made sure there were no xapian libraries in it and 
followed the above yum instructions to install xapian-bindings-perl.  I 
then ran my code using perl -d and found that the code failed as I 
described originally.  See:

main::(gsearch.cgi:97):        $db = Search::Xapian::Database->new( $dx );
   DB<2> l
97==>        $db = Search::Xapian::Database->new( $dx );
98:        my $qp = Search::Xapian::QueryParser->new();
99:        my $dbSize=$db->get_doccount();
100:        $qp->set_stemmer(new Search::Xapian::Stem("english"));
101:        $qp->set_stemming_strategy(STEM_SOME);
102:        $qp->set_default_op($defaultop);
103:        my $par = $qp->parse_query($query);
104:        my $enq = $db->enquire( $par );
105
106:        my @matches = $enq->matches($nstart,$nrecords);
   DB<2> l
107:        my $mset = $enq->get_mset($nstart,$nrecords);
108:        my $est = $mset->get_matches_estimated();
109:        $results{size}=$mset->size();
110:        $results{dbsize}=$dbSize;
111:        $results{estimate}=$est;
112:        $results{start}=$nstart;
113: $results{query}=$enq->get_query->get_description();
114:        my %hits;
115:        my @hits;
116:        my $t1 = [gettimeofday];
   DB<2> l
117:        $results{searchElTime}=tv_interval $t0, $t1;
118:        my $totTime=0;
119:        print "Dbsize $dbSize estimated $est start $nstart\n";
120:        foreach my $match ( @matches ) {
121:            my %hit;
122:            my %ht;
123:            my $doc = $match->get_document();
124:            my $per = $match->get_percent();
125:            my $id = $match->get_docid();
126:            print "ID $id Percent $per Doc $doc\n";
   DB<2> l
127:            my $eterm = $enq->get_matching_terms_end($id);
128:            my $bterm = $enq->get_matching_terms_begin($id);
129:            my @terms;
130:            for(my $xit=$bterm;$xit != $eterm;++$xit) {
131:                my $foo ="$xit";
132:                $foo =~s/^Z//;
133:                $foo =~s/^A//;
134:                push(@terms,$foo);
135:            }
136:            if(!scalar(@terms)) {
   DB<2> c 132
Dbsize 300 estimated 105 start 0
ID 120 Percent 100 Doc Search::Xapian::Document=HASH(0x255a148)
main::(gsearch.cgi:132):                $foo =~s/^Z//;
   DB<3> p $foo
Search::Xapian::TermIterator=HASH(0x255a208)
   DB<4>
When it's running right, $foo contains the word "book" which is the 
complete query.

Jim.




More information about the Xapian-discuss mailing list