| Search-OpenSearch documentation | view source | Contained in the Search-OpenSearch distribution. |
Search::OpenSearch::Engine - abstract base class
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, # count total only (same as f=0 r=0)
L => 'field|low|high', # limit results to inclusive range
f => 1, # include facets
r => 1, # include results
format => 'XML', # or JSON
link => 'http://yourdomain.foo/opensearch/',
b => 'AND', # or OR
);
print $response;
Search::OpenSearch::Engine is an abstract base class. It defines some sane method behavior based on the SWISH::Prog::Searcher API.
This class is a subclass of Rose::ObjectX::CAF. Only new or overridden methods are documented here.
Sets up the new object.
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.
See the SYNOPSIS.
Returns a Search::OpenSearch::Response object based on the format specified in args.
Called internally by search(). The args will be three key/value pairs, with keys "field," "low", and "high".
Get/set a Search::OpenSearch::Facets object.
Get/set the location of the inverted indexes to be searched. The value is intented to be used in init_searcher().
The value returned by init_searcher().
Get/set the arrayref of field names to be fetched for each search result.
Should return a unique identifier for your Engine subclass. Default is to croak().
The base URI for Responses. Passed to Response->link.
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.
Default will croak. Engine subclasses must implement this method to provide Facet support.
results should be an iterator like SWISH::Prog::Results.
Returns an array ref of hash refs, each corresponding to a single search result.
Called by build_results for each result object. hash_of_args is a list of key/value pairs that includes:
The values returned from results->next.
A Search::Tools::HiLiter object.
A Search::Tools::Snipper object.
A Search::Tools::XML object.
Array ref of fields defined in the new() constructor.
Returns a hash ref, where each key is a field name.
Get/set the internal CHI object. Defaults to the File driver.
Get/set the cache key time-to-live. Default is 1 hour.
Get/set the hash ref of field names that should not be hilited in a Response.
Get/set the hash ref of Search::Tools::Snipper->new params.
Get/set the hash ref of Search::Tools::HiLiter->new params.
Get/set the hash ref of Search::Tools::QueryParser->new params.
By default, looks up field_name in the do_no_hilite() hash, but you can override this method to implement whatever logic you want.
Get/set an optional logging object, which must implement a method called log and expect a single string.
Override this method in a subclass in order to indicate support for more than just searching an index. Examples include support for DELETE, PUT, POST and GET HTTP methods on particular documents in the index.
Default is false.
Get/set the debug flag for messaging on stderr.
Peter Karman, <karman at cpan.org>
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.
You can find documentation for this module with the perldoc command.
perldoc Search::OpenSearch
You can also look for information at:
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.
| Search-OpenSearch documentation | view source | Contained in the Search-OpenSearch distribution. |