Lucy::...::Hits(3pm)

πŸ“¦
version 0.6.2 Β· 2 versions
, in fedora 43

πŸ’– Lucy::...::Hits(3pm) πŸ’–

okay bestie, so this is the manual page for Lucy::Search::Hits β€” yeah the title up there says Lucy::...::Hits and the man name is 3pm because it's a Perl module doc, but the actual thing we're talking about is Lucy::Search::Hits. buckle up, it's short and it's cute.


✨ NAME ✨

Lucy::Search::Hits β€” the way you get at your search results. like, the whole point. πŸ’…


🌸 SYNOPSIS 🌸

here's the vibe, no cap:

my $hits = $searcher->hits(
    query      => $query,
    offset     => 0,
    num_wanted => 10,
);
while ( my $hit = $hits->next ) {
    print "<p>$hit->{title} <em>" . $hit->get_score . "</em></p>\n";
}

look at her go 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so Hits objects are iterators β€” lil machines that hand you the results of a search one at a time. that's the whole job. they iterate. they're the main character of your search pipeline, fr fr.


πŸŽ€ METHODS πŸŽ€

⭐ next

my $hit_doc = $hits->next();

gives you the next hit, and when the iterator is fully exhausted (nothing left, empty, donezo) it hands you undef. so like, always check before you go dereferencing, okay? 😭

⭐ total_hits

my $int = $hits->total_hits();

returns the total number of documents that matched the Query that produced this Hits object. and ngl this is important: it's the total number of matches, not just the number of matches that the Hits iterator is representing. so if your iterator only walks through some of them, this number is still the whole entire count. πŸ’―


πŸ‘‘ INHERITANCE πŸ‘‘

Lucy::Search::Hits isa Clownfish::Obj.

so yeah, she's got Clownfish blood. iconic lineage honestly. 🌈


and that's the whole page, bestie β€” go forth and iterate responsibly. mwah. πŸ’œ

this was perl v5.42.0, dated 2025-07-25 β€” documented by the User Contributed Perl Documentation crew, and yes, the source and version are right there in the footer, slay. πŸŽ€βœ¨

πŸ“¦ where this page comes from