Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: kinosearch: discuss

Lexicon and PostingList now public

 

 

kinosearch discuss RSS feed   Index | Next | Previous | View Threaded


marvin at rectangular

Feb 26, 2008, 8:19 PM

Post #1 of 1 (687 views)
Permalink
Lexicon and PostingList now public

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
http://www.rectangular.com/mailman/listinfo/kinosearch

kinosearch discuss RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.