Plucen...estCase(3pm)
π Plucene::TestCase β the manual page, but make it a group chat π
okay so bestie, welcome to Plucene::TestCase, a 3pm page from the User Contributed Perl Documentation corner of the universe π«Ά. It's the little toolkit of Handy functions you reach for when you're testing Plucene, and honestly? it's giving "test helper that carries the whole squad" β¨.
πΈ NAME πΈ
Plucene::TestCase β Handy functions when testing Plucene π
β¨ SYNOPSIS β¨
look, here's the whole vibe, verbatim, no cap:
use Test::More tests => 10;
use Plucene::TestCase;
new_index {
add_document( foo => "bar" );
};
re_index {
add_document( foo => "baz" );
}
with_reader {
$READER->whatever;
}
my $hits = search("foo:ba*");
that's it, that's the whole energy π₯. you set up an index, you re-index, you poke at a reader, you search. slay.
π EXPORTS π
these are the little gifts this module hands you when you use it π:
$DIRβ a directory that gets created just for this test, and that's where the index lives. It normally gets cleaned up at the end of the test... unless$Plucene::TestCase::DEBUGis set, in which case it sticks around so you can peruse the entrails ππ. (yes, "entrails". iconic phrasing, we don't ask questions.)$WRITERβ a variable holding the currentIndex::Writerobject, if there is one ποΈ.$READERβ a variable holding the currentIndex::Readerobject, if there is one π.$ANALYZERβ a variable holding the class name of the desiredAnalysis::Analyzerclass π§ͺ.
π« the functions, one by one π«
new_index BLOCK (Analyzer)β creates a brand new index, and does all the stuff in the block before closing the index writer π.$WRITERis set for the duration of the block, so go wild inside it. The optional parameter should be the class name of the analyzer you want to use; if you don't specify one, it takes the value from$ANALYZER, which itself defaults toPlucene::Analysis::SimpleAnalyzer. so like, if you say nothing, you get the simple one. periodt.re_index BLOCK (Analyzer)β literally the same asnew_index, except it doesn't make a new index, it re-uses an old one β»οΈ. same block energy, same optional analyzer parameter situation.add_document( field1 => value1, ...)β adds a new document to the index, with the given fields and values π. that's the whole thing, bestie, go forth and add documents.with_reader BLOCKβ opens an index reader in$READERand runs the block π¦.searchβ searches for the query you give it π. If any fields are not specified, they'll be assumed to be the defaulttext. Returns aPlucene::Search::Hitsobject, which is your little bag of results πβ¨. The value of$ANALYZERwill be used to construct an analyzer for the query string.
π POD ERRORS π
Hey! The above document had some coding errors, which are explained below:
- Around line 49:
=over without closing =back
bestie. the doc itself has an unclosed =over. it's giving "left me on read" π. not me pointing it out, the manpage literally says so. iykyk.
and that's the whole page, fr fr π
this was perl v5.36.0, dated 2022-12-04, and it lives under the Plucen...estCase(3pm) title in the User Contributed Perl Documentation. thanks for coming to my ted talk, mwah π
π
π¦ 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