Dezi::Config - Dezi server configuration


 use Dezi::Config;
 use CHI;         # optional, see cache below
 use Dezi::UI;    # optional, see ui_class and ui below
 use Dezi::Admin; # optional, see admin_class and admin below
 use Dezi::Stats; # optional, see stats_logger below

 my $dezi_config = Dezi::Config->new({
    search_path     => '/search',
    index_path      => '/index',
    commit_path     => '/commit',
    rollback_path   => '/rollback',
    ui_path         => '/ui',
    ui_class        => 'Dezi::UI',
    # or
    # ui              => Dezi::UI->new()
    admin_path      => '/admin', 
    admin_class     => 'Dezi::Admin',
    # or
    # admin           => Dezi::Admin->new(),
    base_uri        => '',
    server_class    => 'Dezi::Server',
    # authentication for non-idempotent requests.
    # if both username && password are defined,
    # then /index, /commit and /rollback require
    # basic authentication credentials.
    username        => 'someone',
    password        => 'somesecret',
    # optional
    # see Dezi::Stats
    stats_logger => Dezi::Stats->new(
        type        => 'DBI',
        dsn         => 'DBI::mysql:database=mydb;host=localhost;port=3306',
        username    => 'myuser',
        password    => 'mysecret',
    # see Search::OpenSearch::Engine
    engine_config => {

        default_response_format => 'JSON',
        # could be any Search::OpenSearch::Engine::* class
        type    => 'Lucy',

        # name of the index(es)
        index   => [qw( path/to/your.index )],

        # which facets to calculate, and how many results to consider
        facets => {
            names       => [qw( color size flavor )],
            sample_size => 10_000,

        # result attributes in response
        fields => [qw( color size flavor )],

        # options passed to indexer defined by Engine type (above)
        # defaults to Dezi::Lucy::Indexer->new
        indexer_config => {
            # see Dezi::Indexer::Config
            # and
            config => { 

                # searchable fields
                MetaNames => 'color size flavor',

                # attributes to store
                PropertyNames => 'color size flavor',

                # auto-vivify new fields based on POSTed docs.
                # use this if you want ElasticSearch-like effect.
                UndefinedMetaTags => 'auto',

                # treat unknown mime types as text/plain
                DefaultContents => 'TXT',

                # use English snowball stemmer
                FuzzyIndexingMode => 'Stemming_en1',


            # store token positions to optimize snippet creation
            highlightable_fields => 1,

        # options passed to searcher defined by Engine type (above)
        # defaults to Dezi::Lucy::Searcher->new
        searcher_config => {
            max_hits             => 1000,
            find_relevant_fields => 1,
            qp_config => {
                dialect   => 'Lucy',
                null_term => 'NULL',
                # see Search::Query::Parser and Search::Query::Dialect::Lucy
                # for full list of options

        # see LucyX::Suggester
        suggester_config => {
            limit  => 10,
            fields => [qw( color size )],

            # passed to Search::Tools::Spellcheck->new
            # along with parser_config
            spellcheck_config => {
                lang => 'en_US',

        # cache facets for speed-up.
        # this is the Search::OpenSearch default setting
        cache => CHI->new(
            driver           => 'File',
            dir_create_mode  => 0770,
            file_create_mode => 0660,
            root_dir         => "/tmp/opensearch_cache",
        # how long should the facet cache live
        # each cache entry is per-unique-query
        cache_ttl => 3600,

        # explicitly turn off highlighting for some fields
        do_not_hilite => { color => 1 },

        # see Search::Tools::Snipper
        snipper_config => { as_sentences => 1, strip_markup => 1, },

        # see Search::Tools::HiLiter
        hiliter_config => { class => 'h', tag => 'b' },

        # see Search::Tools::QueryParser
        parser_config => {},

        # see Search::OpenSearch::Engine::Lucy
        auto_commit => 1, # set to 0 to enable transactions with /commit and /rollback



Dezi::Config parses configuration settings, applies default values, and instantiates component objects for Dezi::Server.

Mostly this class exists in order to document, in one location, all the options available for the Dezi server. You will rarely use Dezi::Config directly; it is intended as an internal class for use by Dezi::Server. Instead, your file contents are parsed by Dezi::Config and applied to the server application.

The SYNOPSIS section provides all the default configuration values, with comments indicating where more complete documentation may be available for the relevant components. The rest of the documentation below is specific to this class and probably not what you're looking for as a Dezi user.


new( hashref )

See the SYNOPSIS for a complete description of the keys/values supported in hashref.

The following hashref keys are also supported as accessor/mutator methods on the object returned from new():



Internal method called by new().


Internal method. Some convenient arg munging for new().


Returns an instance of ui_class if set.


Returns an instance of admin_class if set.

apply_default_engine_config( hashref )

Default Search::OpenSearch::Engine options are applied directly to hashref. This method is called internally by new().


If username and password are passed to new(), the authenticator() method will return a CODE ref for passing to Plack::Middleware::Auth::Basic.


Returns the object as a plain Perl hash of key/value pairs.


Peter Karman, <karman at>


Please report any bugs or feature requests to bug-dezi 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 Dezi::Config

You can also look for information at:


Copyright 2012-2018 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.


Search::OpenSearch, Search::Tools, SWISH::3, Dezi::App, Plack, Lucy