NAME
Search::OpenSearch::Engine - abstract base class
SYNOPSIS
use Search::OpenSearch::Engine;
my $engine = Search::OpenSearch::Engine->new(
index => [qw( path/to/index1 path/to/index2 )],
facets => {
names => [qw( color size flavor )],
sample_size => 10_000,
},
fields => [qw( color size flavor )],
);
my $response = $engine->search(
q => 'quick brown fox', # query
s => 'rank desc', # sort order
o => 0, # offset
p => 25, # page size
h => 1, # highlight query terms in results
c => 0, # return count stats only (no results)
L => 'field|low|high', # limit results to inclusive range
f => 1, # include facets
format => 'XML', # or JSON
link => 'http://yourdomain.foo/opensearch/',
);
print $response;
DESCRIPTION
Search::OpenSearch::Engine is an abstract base class. It defines some sane method behavior based on the SWISH::Prog::Searcher API.
METHODS
This class is a subclass of Rose::ObjectX::CAF. Only new or overridden methods are documented here.
init
Sets up the new object.
init_searcher
Subclasses must implement this method. If the Searcher object acts like a SWISH::Prog::Searcher, then search() will Just Work. Otherwise, your Engine subclass should likely override search() as well.
search( args )
See the SYNOPSIS.
Returns a Search::OpenSearch::Response object based on the format specified in args.
set_limit( args )
Called internally by search(). The args will be three key/value pairs, with keys "field," "low", and "high".
facets
Get/set a Search::OpenSearch::Facets object.
index
Get/set the location of the inverted indexes to be searched. The value is intented to be used in init_searcher().
searcher
The value returned by init_searcher().
fields
Get/set the arrayref of field names to be fetched for each search result.
type
Should return a unique identifier for your Engine subclass. Default is to croak().
link
The base URI for Responses. Passed to Response->link.
get_facets( query, results )
Checks the cache for facets related to query and, if found, returns them. If not found, calls build_facets(), which must be implemented by each Engine subclass.
build_facets( query, results )
Default will croak. Engine subclasses must implement this method to provide Facet support.
cache
Get/set the internal CHI object. Defaults to the File driver.
cache_ttl
Get/set the cache key time-to-live. Default is 1 hour.
AUTHOR
Peter Karman, <karman at cpan.org>
BUGS
Please report any bugs or feature requests to bug-search-opensearch at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Search-OpenSearch. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Search::OpenSearch
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
COPYRIGHT & LICENSE
Copyright 2010 Peter Karman.
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.