The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

OpenInteract2::Manual::SearchResults - Managing Search Results in OpenInteract2

SYNOPSIS

This part of the manual briefly describes how to save search results and retrieve them later, either piecemeal or all at once.

DESCRIPTION

OpenInteract2 comes with the ability to serialize and later retrieve search results. This enables users to run large-ish searches and have the results be accessible at a later time, or in a paged result form (Page 1 of 12, results 1 - 20, etc.) without running the entire search again and ensuring that successive pages are consistent..

OpenInteract2 comes with two classes to perform these actions. The main one is OpenInteract2::ResultsManage, which serializes and retrieves the results. The other is OpenInteract2::ResultsIterator, which is an implementation of SPOPS::Iterator that works with the first class to kick out results one at a time.

Example

First we'll get a list of objects from some method perform_search() (it doesn't matter what this is) and serialize them:

 my $object_list = perform_search( ... );
 my $results = OpenInteract2::ResultsManage->new();
 my $search_id = $results->save( $object_list );

Next, we'll use that same search ID to retrieve the resultset and get the first 50 entries back:

 my $search_id = $request->param( 'search_id' );
 my $results = OpenInteract2::ResultsManage->new({
     search_id => $search_id
 });
 my $iterator = $results->retrieve({ max => 50 });

Later we'll retrieve results 51 to 100 from the resultset:

 my $search_id = $request->param( 'search_id' );
 my $results = OpenInteract2::ResultsManage->new({
     search_id => $search_id
 });
 my $iterator = $results->retrieve({ min => 51, max => 100 });

SEE ALSO

OpenInteract2::ResultsManage has the implementation documentation and more examples.

COPYRIGHT

Copyright (c) 2002-2005 Chris Winters. All rights reserved.

AUTHORS

Chris Winters <chris@cwinters.com>