.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "KinoSearch1::Search::Hits 3pm" .TH KinoSearch1::Search::Hits 3pm 2024-03-10 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME KinoSearch1::Search::Hits \- access search results .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 5 \& my $hits = $searcher\->search( query => $query ); \& $hits\->seek( 0, 10 ); \& while ( my $hashref = $hits\->fetch_hit_hashref ) { \& print "

$hashref\->{title} $hashref\->{score}

\en"; \& } .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" Hits objects are used to access the results of a search. By default, a hits object provides access to the top 100 matches; the \fBseek()\fR method provides finer-grained control. .PP A classic application would be paging through hits. The first time, 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 \-\- seek to a START of 10, and retrieve 10 more documents. And so on. .SH METHODS .IX Header "METHODS" .SS seek .IX Subsection "seek" .Vb 1 \& $hits\->seek( START, NUM_TO_RETRIEVE ); .Ve .PP Position the Hits iterator at START, and capture NUM_TO_RETRIEVE docs. .SS total_hits .IX Subsection "total_hits" .Vb 1 \& my $num_that_matched = $hits\->total_hits; .Ve .PP Return the total number of documents which matched the query used to produce the Hits object. (This number is unlikely to match NUM_TO_RETRIEVE.) .SS fetch_hit .IX Subsection "fetch_hit" .Vb 3 \& while ( my $hit = $hits\->fetch_hit ) { \& # ... \& } .Ve .PP Return the next hit as a KinoSearch1::Search::Hit object. .SS fetch_hit_hashref .IX Subsection "fetch_hit_hashref" .Vb 3 \& while ( my $hashref = $hits\->fetch_hit_hashref ) { \& # ... \& } .Ve .PP Return the next hit as a hashref, with the field names as keys and the field values as values. An entry for \f(CW\*(C`score\*(C'\fR will also be present, as will an entry for \f(CW\*(C`excerpt\*(C'\fR if \fBcreate_excerpts()\fR was called earlier. However, if the document contains stored fields named "score" or "excerpt", they will not be clobbered. .SS create_excerpts .IX Subsection "create_excerpts" .Vb 4 \& my $highlighter = KinoSearch1::Highlight::Highlighter\->new( \& excerpt_field => \*(Aqbodytext\*(Aq, \& ); \& $hits\->create_excerpts( highlighter => $highlighter ); .Ve .PP Use the supplied highlighter to generate excerpts. See KinoSearch1::Highlight::Highlighter. .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright 2005\-2010 Marvin Humphrey .SH "LICENSE, DISCLAIMER, BUGS, etc." .IX Header "LICENSE, DISCLAIMER, BUGS, etc." See KinoSearch1 version 1.01.