Peter Karman


Search::OpenSearch::Engine::Lucy - Lucy server with OpenSearch results


 use Search::OpenSearch::Engine::Lucy;
 my $engine = Search::OpenSearch::Engine::Lucy->new(
    index       => [qw( path/to/index1 path/to/index2 )],
    facets      => {
        names       => [qw( color size flavor )],
        sample_size => 10_000,
    fields      => [qw( color size flavor )],   # result attributes in response
    indexer_config  => {
        somekey => somevalue,
    searcher_config => {
        anotherkey => anothervalue,
    suggester_config => {
        spellcheck_config => {
            lang => 'en_US',
        limit => 10,
    aggregator_class => 'MyAggregator', # defaults to Dezi::Aggregator
    cache           => CHI->new(
        driver           => 'File',
        dir_create_mode  => 0770,
        file_create_mode => 0660,
        root_dir         => "/tmp/opensearch_cache",
    cache_ttl       => 3600,
    do_not_hilite   => [qw( color )],
    snipper_config  => { as_sentences => 1, strip_markup => 1, }, # see Search::Tools::Snipper
    hiliter_config  => { class => 'h', tag => 'b' }, # see Search::Tools::HiLiter
    parser_config   => {},                           # see Search::Query::Parser
 my $response = $engine->search(
    q           => 'quick brown fox',   # query
    s           => 'score 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
    t           => 'XML',               # or JSON
    u           => '',
    b           => 'AND',               # or OR
 print $response;



Returns Lucy.


Passed as param to new(). This class is used for filtering incoming docs via the aggregator's swish_filter() method.

auto_commit( 0 | 1 )

Set this in new().

If true, a new indexer is spawned via init_indexer() for each POST, PUT or DELETE.

If false, the same indexer is re-used in POST, PUT or DELETE calls, until COMMIT or ROLLBACK is called.

Default is true (on).


Overrides base method to load the aggregator_class and other Engine-specific construction tasks.


Returns a Dezi::Lucy::Searcher object.


Returns a Dezi::Lucy::Indexer object (used by the REST API).


Returns a LucyX::Suggester object. You can configure it as described in the SYNOPSIS.

build_facets( query, results )

Returns hash ref of facets from results. See Search::OpenSearch::Engine.

process_result( args )

Overrides base method to preserve multi-value fields as arrays.


Returns true.


Returns array (not an array ref) of supported HTTP method names. These correspond to the UPPERCASE method names below.

NOTE that COMMIT and ROLLBACK are not official HTTP/1.1 method names.

PUT( doc )

Writes doc to the first index defined. doc must already exist.

POST( doc )

Writes doc to the first index defined. doc may be new or already exist.

DELETE( uri )

Deletes uri from all indexes.

GET( uri )

Fetches uri from all indexes.


If auto_commit is false, use this method to conclude a transaction.


If auto_commit is false, use this method to abort a transaction.


Peter Karman, <karman at>


Please report any bugs or feature requests to bug-search-opensearch-engine-lucy at, or through the web interface at 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::Engine::Lucy

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 for more information.