[Xapian-discuss] Get PositionList from the Mset

James Aylett james-xapian at tartarus.org
Wed Nov 12 23:16:51 GMT 2008


On Wed, Nov 12, 2008 at 05:13:20PM -0500, zhiguo li wrote:

> I was trying to use the TermIterator to get the position list, but when I
> tried it, I got [an] error.
>
> Actually I didn't expect it to work since I need to specify in which
> document to get the PositionList. But when I called  t.positionlist_begin()
> (suppose 't' is a TermIterator), I didn't specity which document to work on.

You aren't quite right, but this is what I didn't check, and it
doesn't work. However you can use the matching terms iterator to then
pull a TermIterator out of your Document, something like:

Xapian::Document d = mset_iter.get_document();
Xapian::TermListIterator tli = d.termlist_begin();
/* now do this for everything coming out of the get_matching_terms
iterator, which we'll call matching */
tli.skip_to(matching.get_term());
if (tli.get_term() == matching.get_term()) {
  Xapian::PositionListIterator = tli.positionlist_begin();
  /* and do whatever you want... */
} else {
  /* this term isn't in this document */
}

Which looks to me like it works (albeit via the Python bindings for
convenience).

J

-- 
/--------------------------------------------------------------------------\
  James Aylett                                                  xapian.org
  james at tartarus.org                               uncertaintydivision.org



More information about the Xapian-discuss mailing list