[Xapian-discuss] allterms() in Python

Francis Irving
Thu, 23 Nov 2006 15:01:01 -0000

xapian_db is a WriteableDatbase. If I do this ...

for term in xapian_db.allterms():
    pass

I get this error ...

Traceback (most recent call last):
  File "./xapdex.py", line 274, in ?
    check_removed_docs(xapian_db)
  File "./xapdex.py", line 254, in check_removed_docs
    for term in xapian_db.allterms():
  File "/usr/lib/python2.4/site-packages/xapian.py", line 864, in next
    r = [self.iter.get_term(), self.iter.get_wdf(), self.iter.get_termfreq(),
PositionIter(self.iter.positionlist_begin(), self.iter.positionlist_end())]
  File "/usr/lib/python2.4/site-packages/xapian.py", line 169, in
positionlist_begin
    def positionlist_begin(*args): return
_xapian.TermIterator_positionlist_begin(*args)
RuntimeError: InvalidOperationError: positionlist_begin not supported

Using the iterators works fine:

t = xapian_db.allterms_begin()
while t != xapian_db.allterms_end():
    t.next()

I'd prefer the more Python syntax, which works fine for msets.

I'm using libxapian13 0.9.9-1.99edgy on Ubuntu.

Francis