| 1 | package SWISH::Prog::Results; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | use base qw( SWISH::Prog::Class ); | ||
| 5 | use Carp; | ||
| 6 | |||
| 7 | our $VERSION = '0.75'; | ||
| 8 | |||
| 9 | __PACKAGE__->mk_accessors( | ||
| 10 | qw( | ||
| 11 | hits | ||
| 12 | query | ||
| 13 | ), | ||
| 14 | ); | ||
| 15 | |||
| 16 | =head1 NAME | ||
| 17 | |||
| 18 | SWISH::Prog::Results - base results class | ||
| 19 | |||
| 20 | =head1 SYNOPSIS | ||
| 21 | |||
| 22 | my $searcher = SWISH::Prog::Searcher->new( | ||
| 23 | invindex => 'path/to/index', | ||
| 24 | query_class => 'SWISH::Prog::Query', | ||
| 25 | query_parser => $swish_prog_queryparser, | ||
| 26 | ); | ||
| 27 | |||
| 28 | my $results = $searcher->search( 'foo bar' ); | ||
| 29 | while (my $result = $results->next) { | ||
| 30 | printf("%4d %s\n", $result->score, $result->uri); | ||
| 31 | } | ||
| 32 | |||
| 33 | =head1 DESCRIPTION | ||
| 34 | |||
| 35 | SWISH::Prog::Results is a base results class. It defines | ||
| 36 | the APIs that all SWISH::Prog storage backends adhere to in | ||
| 37 | returning results from a SWISH::Prog::InvIndex. | ||
| 38 | |||
| 39 | =head1 METHODS | ||
| 40 | |||
| 41 | =head2 query | ||
| 42 | |||
| 43 | Should return the search query as it was evaluated by the Searcher. | ||
| 44 | |||
| 45 | =head2 hits | ||
| 46 | |||
| 47 | Returns the number of matching documents for the query. | ||
| 48 | |||
| 49 | =head2 next | ||
| 50 | |||
| 51 | Return the next Result. | ||
| 52 | |||
| 53 | =cut | ||
| 54 | |||
| 55 | sub next { | ||
| 56 | croak "must override next() in your subclass"; | ||
| 57 | } | ||
| 58 | |||
| 59 | 1; | ||
| 60 | |||
| 61 | __END__ |