Plucen...Reader(3pm)
β¨ Plucene::Index::Reader β the abstract baddie for accessing an index β¨
okay bestie, listen up π this is Plucene::Index::Reader from the User Contributed Perl Documentation, and it's giving abstract class energy β like, it's the vibe, not the full outfit. let's get into it π
πΈ NAME πΈ
Plucene::Index::Reader β the abstract class for accessing an index. no cap, that's literally it π
π¦ DESCRIPTION π¦
okay so. IndexReader is an abstract class, and what it does is provide an interface for accessing an index. and here's the slay part β searching an index happens entirely through this abstract interface, which means literally any subclass that implements it is automatically searchable. iconic behavior honestly π
concrete subclasses of IndexReader are usually constructed with a call to the static method open. that's the move. that's how you get one β¨
and now for the efficiency tea β β in this API, documents are often referred to via document numbers: non-negative integers, each one naming a unique document in the index. but bestie, these document numbers are ephemeral β they may change as documents get added to and deleted from an index. so clients should not rely on a given document having the same number between sessions. fr fr, do not do that. it's giving undefined behavior and we're not about that life π
π METHODS π
π new
my $reader = Plucene::Index::Reader->new($dir_name);
this creates a new Plucene::Index::Reader with the directory you passed in. that's it, that's the whole thing π«Ά
π open
# If there is only one segment
my Plucene::Index::SegmentReader $seg_read = $reader->open;
# If there are many segments
my Plucene::Index::SegmentsReader $seg_read = $reader->open;
returns an IndexReader reading the index in the given Directory. one segment, many segments, doesn't matter β it's got you π«
β last_modified
my $last_modified = Plucene::Index::Reader->last_modified($directory);
yep. that's the one. returns the last modified, as you'd expect π
π§ index_exists
if (Plucene::Index::Reader->index_exists($directory)){ ... }
does the index exist? check it and find out bestie π
π is_locked
if (Plucene::Index::Reader->is_locked($directory)){ ... }
is it locked? the vibes will tell you π
π delete
$reader->delete($doc);
deletes the doc. bye bye π«‘
π delete_term
$reader->delete_term($term);
this will delete all the documents which contain the passed term. all of them. every single one. periodt πͺοΈ
π₯ close
$reader->close;
closes it. we love a clean exit β¨
π unlock
$reader->unlock($directory);
unlocks the directory. freedom π¦
π and then there's these onesβ¦
these must be defined in a subclass β no exceptions, bestie, they're abstract for a reason:
num_docsmax_docdocumentis_deletednormstermsdoc_freqterm_docsterm_positions_do_delete_do_close
like, genuinely, if you're subclassing this, you have to define all of them. it's not optional and it's not a suggestion. it's giving homework π
okay that's the whole page, you ate it, you understood it, you're basically a search engine engineer now πβ¨
this has been Plucen...Reader(3pm) β written up against perl v5.36.0, dated 2022-12-04. mwah, love you, bye ππ
π
π¦ where this page comes from
- debian bookworm: libplucene-perl 1.25-5
- debian trixie: libplucene-perl 1.25-5
- ubuntu noble: libplucene-perl 1.25-5
- ubuntu resolute: libplucene-perl 1.25-5
- ubuntu stonking: libplucene-perl 1.25-5
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms