[Xapian-discuss] Perl example of using termitrator?
Jim
jim at fayettedigital.com
Sun Sep 30 22:35:00 BST 2007
I'm having trouble translating from C++ to perl objects.
The TermIterator class looks like to get a set of terms in a document
you might have C++ code like:
Enquire::TermIterator termIt =enquire->get_matching_terms_begin(id);
for(;termIt != enquire->get_matching_terms_end(id);termIt++) {
string term = *termIt;
}
Or something similar. However when I attempt to translate that into
perl, I am trying:( I am working in the blind here)
foreach my $match ( @matches ) {
my %hit;
my %ht;
my $doc = $match->get_document();
my $per = $match->get_percent();
my $id = $match->get_docid();
my $bterm = $enq->get_matching_terms_begin($id);
for(my $xit=$bterm;$xit !=
$enq->get_matching_terms_end($id);$xit++) {
my $term=$xit;
print $term;
}
Which doesn't really make any sense. Xit is a string and I don't see
how incrementing a string will do anything useful. So how do you
increment the iterator?
I feel like there's got to be some documentation I'm missing somewhere.
This does return the terms until it hits the end case then it hangs,
perl just keeps clocking time. I have to kill it.
If I run the following, the same thing happens:
my %eterm = $enq->get_matching_terms_end($id);
More information about the Xapian-discuss
mailing list