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.
facet_names
Returns an array of all the keys of facets
.
facets
HashRef of facet for this query. The HashRef is keyed by the name of the facet and the values are facet's value.
items
The list of Data::SearchEngine::Items found for the query.
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.
Gets the facet with the specified name. Returns undef if one does not exist.
Sets the facet with the specified name.
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 117:
Unknown directive: =head
- Around line 121:
Unknown directive: =head
- Around line 125:
Unknown directive: =head
- Around line 129:
Unknown directive: =head
- Around line 133:
Unknown directive: =head