[Xapian-discuss] Get PositionList from the Mset

zhiguo li zhiguo.li at gmail.com
Thu Nov 13 00:31:11 GMT 2008


Thanks James, finally I used the following way to make it work. It involves
using the database though.

db.positionlist_begin(*im, *it);

where "db" is the database, "im" is the MSetIterator and "it" is the
TermIterator.
Kevin
On Wed, Nov 12, 2008 at 6:16 PM, James Aylett <james-xapian at tartarus.org>wrote:

> 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
>
> _______________________________________________
> Xapian-discuss mailing list
> Xapian-discuss at lists.xapian.org
> http://lists.xapian.org/mailman/listinfo/xapian-discuss
>


More information about the Xapian-discuss mailing list