Data::SearchEngine::Results - Results of a Data::SearchEngine search
version 0.32
# An example search implementation sub search { my ($self, $query) = @_; # boring, search specific implementation my $results = Data::SearchEngine::Results->new( query => $query, pager => Data::SearchEngine::Paginator->new # Data::Paginator subclass ); my @sorted_products; # fill with a search or something my $scores; # fill with search scores my $start = time; foreach my $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; }
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.
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' });
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.
The Data::Page for this result.
An attribute that a search backend may fill with the "raw" response it received. This is useful for retrieving engine-specific information such as debugging or tracing information. Type is Any.
Any
Add an item to this result.
Get the nth item.
Cory G Watson <gphat@cpan.org>
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.
To install Data::SearchEngine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::SearchEngine
CPAN shell
perl -MCPAN -e shell install Data::SearchEngine
For more information on module installation, please visit the detailed CPAN module installation guide.