Dancer2::Plugin::ElasticSearch - Dancer2 plugin for obtaining Search::Elasticsearch handles
version 0.004
use Dancer2::Plugin::ElasticSearch; get '/count_all_docs' => sub { return elastic->search(search_type => 'count', body => { query => { match_all => {} } }); }
This Dancer2 plugin handles connection configuration and fork-and-thread safety for ElasticSearch connectors.
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 new connection is created, ping is immediately called to check it; this may throw an exception if there is in fact an issue with the cluster.
ping
If a configuration name is not passed, "default" is assumed.
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
params
elastic
elastic('default')
Search::Elasticsearch->new(nodes => 'localhost:9200');
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.
D2_PLUGIN_ES
Search::Elasticsearch, Dancer2
Fabrice Gabolde <fgabolde@weborama.com>
This software is copyright (c) 2018 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.
To install Dancer2::Plugin::ElasticSearch, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer2::Plugin::ElasticSearch
CPAN shell
perl -MCPAN -e shell install Dancer2::Plugin::ElasticSearch
For more information on module installation, please visit the detailed CPAN module installation guide.