NAME
Dancer2::Plugin::ElasticSearch - Dancer2 plugin for obtaining Search::Elasticsearch handles
VERSION
version 0.003
SYNOPSIS
use Dancer2::Plugin::ElasticSearch;
get '/count_all_docs' => sub {
return elastic->search(search_type => 'count',
body => { query => { match_all => {} } });
}
DESCRIPTION
This Dancer2 plugin handles connection configuration and fork-and-thread safety for ElasticSearch connectors.
KEYWORDS
elastic
elastic->ping;
elastic('other')->ping;
Return a Search::Elasticsearch::Client subclass suitable for running queries against an ElasticSearch instance. Each thread is guaranteed to have its own client instances. If a connection already exists for a given configuration name, it is returned instead of being re-created.
If a configuration name is not passed, "default" is assumed.
CONFIGURATION
plugins:
ElasticSearch:
default:
params:
nodes: localhost:9200
other:
params: etc
The params
hashref must contain a map of parameters that can be passed directly to the Search::Elasticsearch constructor. In the above example, calling elastic
(or elastic('default')
) will result in
Search::Elasticsearch->new(nodes => 'localhost:9200');
INSTALLATION
You can install this module as you would any Perl module.
During installation, the unit tests will run queries against a local ElasticSearch instance if there is one (read-only queries, of course!). If you have no local ElasticSearch instance, but still wish to run the unit tests, set the D2_PLUGIN_ES
variable to "$host:$port". If no instance can be reached, the tests will be safely skipped.
SEE ALSO
Search::Elasticsearch, Dancer2
AUTHOR
Fabrice Gabolde <fgabolde@weborama.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Weborama.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.