NAME
Data::SearchEngine::Results - Results of a Data::SearchEngine serach
SYNOPSIS
The Results object holds the list of items found during a query. They are usually sorted by a score. This object provides some standard attributes you are likely to use, as well as the ability to serialize via freeze
and thaw
thanks to MooseX::Storage.
use Data::SearchEngine::Item;
use Data::SearchEngine::Results;
use Time::HiRes;
sub query {
# boring, search specific implementation
my $results = Data::SearchEngine::Results->new(
query => $query
total_count => $total
);
my $start = time;
foreach $product (@sorted_products) {
my $item = Data::SearchEngine::Item->new(
id => $product->id, # unique product id
score => $scores->{$product->id} # make your own scores
));
$item->set_value('url', 'http://example.com/product/'.$product->id);
$item->set_value('price', $product->price);
$results->add($item);
}
$results->elapsed(time - $start);
return $results;
}
ATTRIBUTES
elapsed
The time it took to complete this search.
The list of Data::SearchEngine::Items found for the query.
The Data::SearchEngine::Query that yielded this Results object.
METHODS
Appends an Item onto the end of this Results object's item list.
Gets the item at the specified index.
Returns the total number of items found by the query, not just how many where returned (which is influenced by count and page).
AUTHOR
Cory G Watson, <gphat at cpan.org>
COPYRIGHT & LICENSE
Copyright 2009 Cory G Watson
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
5 POD Errors
The following errors were encountered while parsing the POD:
- Around line 87:
Unknown directive: =head
- Around line 91:
Unknown directive: =head
- Around line 97:
Unknown directive: =head
- Around line 101:
Unknown directive: =head
- Around line 105:
Unknown directive: =head