Hello, I am scratching my head at how to use the term iterator in PHP. I would like to know what terms are stored against a document. I have a document called $odoc like so coming from some matches. $i = $matches->begin(); while (!$i->equals($matches->end())) { $n = $i->get_rank() + 1; $odoc = $i->get_document(); $data = $odoc->get_data(); $i->next(); } How do I use the termiterator returned from: $odoc->termlist_begin(); I have tried foreaching on it and that doesn't work. I have tried using reflection to see if I am missing something and found a "next" method. But again I can't seem to get that to work either. Some simple example code would be great! I was only needing this for debugging a document and found "delve" which does the job, but I don't like to be beaten on this one... Cheers John
On Thu, Oct 02, 2008 at 11:22:18AM +0100, John Wards wrote:> I have a document called $odoc like so coming from some matches. > > $i = $matches->begin(); > while (!$i->equals($matches->end())) { > $n = $i->get_rank() + 1; > $odoc = $i->get_document(); > $data = $odoc->get_data(); > $i->next(); > } > > How do I use the termiterator returned from: > > $odoc->termlist_begin();Almost exactly as you're using the MSetIterator $i above, but the method to read the term is get_term() not get_document(). There's more information here: http://xapian.org/docs/bindings/php/> I have tried foreaching on it and that doesn't work.It would be nice if this worked, but nobody's written the wrappers required to implement it yet. Cheers, Olly