[Xapian-discuss] how to access position list

James Aylett james-xapian at tartarus.org
Mon Apr 3 16:41:36 BST 2006


On Mon, Apr 03, 2006 at 09:02:26PM +0530, durga bidaye wrote:

> On seacrching i will obtain the MSet. [...] I need access to the
> position list of term "matching" in doc "story.txt".

Okay - the MSet gives you an MSetIterator, which gives you the
Document.

Similarly, the original Query gives you a TermIterator for the terms
in the query (Xapian::Query.get_terms_begin()).

Using that you can find all the terms in the Query, and for each use
the TermIterator in Document (Xapian::Document.termlist_begin()),
combined with the skip_to() method on TermIterator (eg:
skip_to("happily")) to move to the right term. Then the TermIterator
has positionlist_begin() giving you a position iterator which gives
you the actual termpos (in your case, the line number).

You can also get to the position list directly from Xapian::Database
using positionlist_begin(doc_id, tname), which may prove shorter in
code terms.

J

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



More information about the Xapian-discuss mailing list