[Xapian-discuss] Howto use the term iterator?
John Wards
jwards at whiteoctober.co.uk
Fri Oct 3 11:05:44 BST 2008
On Thu, 2008-10-02 at 13:35 +0100, John Wards wrote:
> > It would be nice if this worked, but nobody's written the wrappers
> > required to implement it yet.
>
> Hmm sounds like a challenge. There is iterator stuff in spl which
> might
> be helpful.
>
Right I've been playing with this today.
I have got it looping by doing this:
foreach($odoc->termlist_begin() as $key=>$term){
echo "{$key}: {$term} <br/>";
}
Key is just integer starting at 0. I am just returning the term for now
as debug. I am planning return the TermIterator, however I have hit
against an issue.
The issue is that foreach needs to know when it hits the end of the
loop. Is there anyway of a TermIterator knowing its the end? I've had a
look at the api and I can't figure it out. I can get the end
TermIterator from the Document but I can't use that if I want to do a
true foreach. I suppose I could pass the end iterator when I call
termlist_begin() but I'd rather use in-build xapian calls.
Cheers
John
More information about the Xapian-discuss
mailing list