Plucen...llector(3pm)
π NAME π
ok so bestie, meet Plucene::Search::HitCollector β the little Perl module that sits next to your searcher and gets a lil ping every time something scores. it's giving callback royalty and honestly? we're obsessed. β¨
this page lives in the 3pm section of the manual, aka the "perl modules, but make it fancy" shelf. π
β¨ SYNOPSIS β¨
the whole vibe is: you pair it up with the IndexSearcher. like a duo. iconic behavior only. π
# used in conjunction with the IndexSearcher
my $searcher = Plucene::Search::IndexSearcher->new($DIRECTORY);
my $hc = Plucene::Search::HitCollector->new( collect =>
sub {
my ($self, $doc, $score) = @_;
...
});
$searcher->search_hc($QUERY, $hc);
πΈ DESCRIPTION πΈ
okay so here's the tea β β this module is used in conjunction with the IndexSearcher. and the way that it works?? every single time a document with a non-zero score gets found, the subref that the HitCollector was made with gets called. like, automatically. no cap. it just rings you up every time something juicy shows up. π¦
no zero-score nonsense invited to the party, btw. if it scored 0, we simply don't call. π
π§ METHODS π§
new π
my $hc = Plucene::Search::HitCollector->new( collect =>
sub {
my ($self, $doc, $score) = @_;
...
});
this will create a new Plucene::Search::HitCollector with the passed subref. that's it. that's the whole ritual. hand it a collect subref and boom π₯ you have yourself a HitCollector, bestie. main character energy from line one. π«Ά
collect π
this is called once for every non-zero scoring document, with the document number and its score.
so like, your subref gets the doc number and the score, one call per qualifying doc, and then it's your moment to shine. β
ngl this is the fun part. every non-zero scoring doc = one call. that's the whole deal, fr fr.
and that's the page, babe π β this was pulled straight from the perl v5.36.0 docs, dated 2022-12-04, filed under Plucen...llector(3pm) in the User Contributed Perl Documentation. mwah, go forth and collect hits ππ
π¦ 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