DESCRIPTION

Search::OpenSearch::Engine is an abstract base class. It defines some sane method behavior based on the Dezi::Searcher API.

METHODS

This class is a subclass of Moose. Only new or overridden methods are documented here.

version

Returns the $VERSION for the Engine.

BUILD

Sets up the new object.

init_indexer

Subclasses must implement this method if they wish to support REST methods (PUT POST DELETE).

init_link

Initialize the link() attribute. This is a builder method.

init_searcher

Subclasses must implement this method. If the Searcher object acts like a SWISH::Prog::Searcher or Dezi::Searcher, then search() will Just Work. Otherwise, your Engine subclass should likely override search() as well.

init_suggester

Subclasses may implement this method. It should return an object that acts like LucyX::Suggester: it should have a method called suggest() which expects a query string and returns an array ref of strings which will be included in the Response under the suggestions key.

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().

suggester

The value returned by init_suggester().

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_cache_key( query, search_args )

Returns a string used to key the facets cache. Override this method in a subclass to implement more nuanced string construction.

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_ttl

do_not_hilite

Get/set the hash ref of field names that should not be hilited in a Response. Typically passed as param in new().

snipper_config

Get/set the hash ref of Search::Tools::Snipper->new params. Typically passed as param in new().

hiliter_config

Get/set the hash ref of Search::Tools::HiLiter->new params. Typically passed as param in new().

parser_config

Get/set the hash ref of Search::Tools::QueryParser->new params. Typically passed as param in new().

indexer_config

Get/set the hash ref available to subclasses that implement a REST API. Typically passed as param in new().

searcher_config

Get/set the hash ref available to subclasses in init_searcher(). Typically passed as param in new().

suggester_config

Get/set the hash ref available to subclasses that implement init_suggester(). Typically passed as param in new().

no_hiliting( field_name )

By default, looks up field_name in the do_no_hilite() hash, but you can override this method to implement whatever logic you want.

logger( logger_object )

Get/set an optional logging object, which must implement a method called log and expect a single string.

has_rest_api( 0|1 )

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_allowed_http_methods

Override this method in a subclass in order to indicate the supported HTTP methods. Assumes has_rest_api() is true.

debug([boolean])

Get/set the debug flag for messaging on stderr.

init_default_response_format

Returns default response format. Defaults to 'XML'.

error

Get/set the error value for the Engine.

array_field_values([boolean])

Return all non-default field values as array refs rather than strings. This supports the multi-value \003 separator used by SWISH::3.