NAME
Data::SearchEngine::Results - Results of a Data::SearchEngine search
VERSION
version 0.22
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.
sub search {
# boring, search specific implementation
my $results = Data::SearchEngine::Results->new(
query => $query
pager => Data::Page->new(...)
);
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;
}
SERIALIZATION
This module uses MooseX::Storage::Deferred to provide serialization. You may serialize it thusly:
my $json = $results->freeze({ format => 'JSON' };
# ...
my $results = Data::SearchEngine::Results->thaw($json, { format => 'JSON' });
ATTRIBUTES
elapsed
The time it took to complete this search.
items
The list of Data::SearchEngine::Items found for the query.
query
The Data::SearchEngine::Query that yielded this Results object.
pager
The Data::Page for this result.
METHODS
add ($item)
Add an item to this result.
get ($n)
Get the nth item.
AUTHOR
Cory G Watson <gphat@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Cold Hard Code, LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.