[KinoSearch] Lexicon and PostingList now public

Marvin Humphrey marvin at rectangular.com
Tue Feb 26 20:19:12 PST 2008



Greets,

In svn trunk, Lexicon and PostingList are now public classes.  So are  
the IndexReader factory methods needed to obtain them.

Lexicon is an iterator which supplies a field's unique terms in sorted  
order.

     my $lexicon = $index_reader->lexicon( field => 'content' );
     while ( $lexicon->next ) {
        say $lexicon->get_term;
     }

PostingList, which is also an iterator, supplies the document numbers  
which match a given term.

     my $posting_list = $index_reader->posting_list( field =>  
'content' );
     $posting_list->seek('foo');
     while ( my $doc_num = $posting_list->next ) {
         say "Matching doc num: $doc_num";
     }

The API for the factory methods is slightly different than what was  
discussed earlier: they take labeled parameters rather than 1-2  
positional arguments.

In both cases, adding a "term" parameter is equivalent to adding a  
call to seek().

     $lexicon = $index_reader->lexicon(
         field => 'content',
         term  => 'foo',
     );
     # same as this:
     $lexicon = $index_reader->lexicon( field => 'content' );
     $lexicon->seek('foo');

     $posting_list = $index_reader->posting_list(
         field => 'content',
         term  => 'foo',
     );
     # same as this:
     $posting_list = $index_reader->posting_list( field => 'content' );
     $posting_list->seek('foo');

Note that a the "term" argument does not take a  
KinoSearch::Index::Term object, but just a string scalar.  This may  
seem a little confusing, but it will become less confusing soon:  
KinoSearch::Index::Term is about to go bye-bye.

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/


_______________________________________________
KinoSearch mailing list
KinoSearch at rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch




More information about the kinosearch mailing list