Plucen...estCase(3pm)

πŸ“¦
version 1.25 Β· 2 versions
  • 1.25 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.25 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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::DEBUG is 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 current Index::Writer object, if there is one πŸ–ŠοΈ.
  • $READER β€” a variable holding the current Index::Reader object, if there is one πŸ“–.
  • $ANALYZER β€” a variable holding the class name of the desired Analysis::Analyzer class πŸ§ͺ.

πŸ’« 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 πŸ‘‘. $WRITER is 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 to Plucene::Analysis::SimpleAnalyzer. so like, if you say nothing, you get the simple one. periodt.
  • re_index BLOCK (Analyzer) β€” literally the same as new_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 $READER and runs the block πŸ¦‹.
  • search β€” searches for the query you give it πŸ”Ž. If any fields are not specified, they'll be assumed to be the default text. Returns a Plucene::Search::Hits object, which is your little bag of results πŸ‘œβœ¨. The value of $ANALYZER will 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