[Xapian-discuss] Search::Xapian and term positions

Olly Betts olly at survex.com
Wed Jan 19 22:17:03 GMT 2005

On Wed, Jan 19, 2005 at 10:26:00PM +0100, Arne Georg Gleditsch wrote:
> Firstly, get_matching_terms_begin1 and
> get_matching_terms_begin2 seem to switched around in Enquire.pm

Oops, so they are!

I've had a quick look, and I think the problem is that this isn't
implemented in C++ yet.  When I say "this" I mean creating a
PositionIterator from the TermIterator which you get from
Enquire::get_matching_terms_begin().  That should be fixed, but it'll
take me a while to get round to it.

However, you can just create one from the database by passing the docid
and termname explicitly:

   my $db = Search::Xapian::Database->new("test");
   my $enq = $db->enquire("xapian");
   my @matches = $enq->matches(0, 100);
   foreach my $match (@matches) {
       my $terms = $enq->get_matching_terms_begin($match);
       my $pos = $db->positionlist_begin($match->get_docid(), $terms->get_termname());

That's probably all that would happen internally anyway, so this
shouldn't be any less efficient.


More information about the Xapian-discuss mailing list