[Xapian-discuss] use TermGenerator to get the term

Ying Liu liux0395 at umn.edu
Thu Oct 29 19:26:58 GMT 2009


Hello all,

I have a question about use the TermGenerator alone by Perl. Someone 
asked this question before and his code is in C++. 
(http://lists.xapian.org/pipermail/xapian-discuss/2008-November/006109.html). 
My code is in Perl. Can I get the term by the position just by 
TermGenerator?

    my $analyzer = Search::Xapian::TermGenerator->new;
    $analyzer->index_text("hello Xapian world");
    my $curr_position = $analyzer->get_termpos();  
    $analyzer->set_termpos(2);  
    $curr_position = $analyzer->get_termpos();
    $analyzer->increase_termpos(1);
    $curr_position =  $analyzer->get_termpos();

If I set the document and then use $doc to iterate the term list, terms 
are order  alphabetically. I don't know how to use the positer().

$analyzer->set_document($doc);
my $termlist_begin = $doc->termlist_begin();
$termlist_begin++;
my $term = $termlist_begin->get_document();


Btw, if I want to use ESet, how to assign the text, similar method like 
index_text for ESet?

Thank you,
Ying



More information about the Xapian-discuss mailing list