KinoSe...h::Hits(3pm)

🌸 NAME 🌸

KinoSearch1::Search::Hits β€” bestie, this is how you actually get at your search results πŸ’– it's like the backstage pass to everything your query turned up.


✨ SYNOPSIS ✨

my $hits = $searcher->search( query => $query );
$hits->seek( 0, 10 );
while ( my $hashref = $hits->fetch_hit_hashref ) {
    print "<p>$hashref->{title} <em>$hashref->{score}</em></p>\n";
}

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so Hits objects are literally the way you access the results of a search, no cap. by default a hits object hands you the top 100 matches β€” like, that's the standard vibe β€” and if you want finer-grained control over which slice of results you're looking at, that's exactly what the seek() method is for πŸ’…

the classic application here? paging through hits πŸŽ€ the first time around, you seek to a START of 0 and retrieve 10 documents. if the user wants to see more β€” and there are more than 10 total hits β€” you seek to a START of 10 and retrieve 10 more documents. and so on, and so on, forever and ever, iconic behavior honestly πŸ‘‘


πŸ’… METHODS πŸ’…

🌟 seek

$hits->seek( START, NUM_TO_RETRIEVE );

positions the Hits iterator at START, and captures NUM_TO_RETRIEVE docs. that's it, that's the whole job, she's simple and she delivers 🫢

🌟 total_hits

my $num_that_matched = $hits->total_hits;

returns the total number of documents that matched the query used to produce the Hits object. heads up bestie: this number is unlikely to match NUM_TO_RETRIEVE 😭 like they're just different things, don't come for me.

🌟 fetch_hit

while ( my $hit = $hits->fetch_hit ) {
    # ...
}

returns the next hit as a KinoSearch1::Search::Hit object. one at a time, like a lil snack 🌸

🌟 fetch_hit_hashref

while ( my $hashref = $hits->fetch_hit_hashref ) {
    # ...
}

returns the next hit as a hashref, with the field names as keys and the field values as values πŸ’– an entry for "score" will also be present, and so will an entry for "excerpt" β€” but only if create_excerpts() was called earlier. and here's the lil plot twist: if the document itself contains stored fields named "score" or "excerpt", those will not be clobbered. your data stays your data, periodt ✨

🌟 create_excerpts

my $highlighter = KinoSearch1::Highlight::Highlighter->new(
    excerpt_field => 'bodytext',
);
$hits->create_excerpts( highlighter => $highlighter );

uses the supplied highlighter to generate excerpts. go peek at KinoSearch1::Highlight::Highlighter for the whole story πŸ‘€


Copyright 2005-2010 Marvin Humphrey


🌈 LICENSE, DISCLAIMER, BUGS, etc. 🌈

See KinoSearch1 version 1.01.


and that's the whole page, bestie!! this lil doc came to you courtesy of perl v5.42.3, dated 2026-08-20, living under the manual name KinoSe...h::Hits(3pm) in the User Contributed Perl Documentation section πŸ’œ mwah, go forth and paginate your hits 🧚⭐

πŸ“¦ where this page comes from