NAME

Data::AnyXfer::Elastic - Elasticsearch support for Data::AnyXfer

DESCRIPTION

This module is responisble for connecting to the correct elasticsearch server(s),
depending on the execution environment. It is the foundation of all
Elasticsearch modules and is extended by Elasticsearch Wrapper modules.

SYNOPSIS

my $elasticsearch = Data::AnyXfer::Elastic->new();

$elasticsearch->ping();
$elasticsearch->connected_to_servers();

VERSION

Version: 1.8

SEE ALSO

L<Search::Elasticsearch>
L<http://www.elasticsearch.org/>

ENVIRONMENT VARIABLES

DATA_ANYXFER_ES_DEBUG

Enables tracing on the underlying elasticsearch client when true.

If the value is a truthy string, and not the number 1, it will be taken as the target to trace to. Acceptable values are: Stderr, Stdout, or a filename.

When set to 1 defaults to Stdout.

ATTRIBUTES

elasticsearch

   my $es = Data::AnyXfer::Elastic->new->elasticsearch();

Returns a Search::Elasticsearch::Client::Direct object for direct usage. In
practice wrapper modules should be used. Data::AnyXfer::Elastic::(.*).
This should be used sparingly and only in circumstances where a wrapper module
cannot be used.

is_inject_index_and_type()

If this attribute is set to true then index name and type is automatically
injected into each method when called. Currently this is only used with
L<Data::AnyXfer::Elastic::Index>.

available_servers

CLASS METHODS

default

Returns a default configured instance of this package (Data::AnyXfer::Elastic).

datafile_dir

Returns the default path that will be used for persisting datafiles, as a Path::Class::Dir object.

This can be set via environment variable DATA_ANYXFER_ES_DATAFILE_DIR.

METHODS

ping()

   my $bool = Data::AnyXfer::Elastic->new->ping();

Returns 1 if able to ping elasticsearch server(s), throws an error otherwise.

build_client

my $client = $self->build_client(
    nodes => [ qw/ some-node-1:9200 some-node-2:9200 / ]
);

Returns an Search::Elasticsearch::Client::Direct object for the supplied nodes.

SILO ARCHITECTURE

client_for(silo_name)

my $elastic = Data::AnyXfer::Elastic->new;

# Connects to the nearest elasticsearch cluster used for most senarios
# where the data can be public
$es = $elastic->client_for('public_data');

# Private data for internal use only, croaks on an app server
$es = $elastic->client_for('private_data');

Returns an Search::Elasticsearch::Client::Direct object for the requested silo.

all_clients_for(silo_name)

my $elastic = Data::AnyXfer::Elastic->new;

# Get all clients
my @targets = $elastic->all_clients_for('all');

# Get just the internal cluster clients
my @targets = $elastic->all_clients_for('private_data');

# Get just the 6dg cluster clients
my @targets = $elastic->all_clients_for('public_data');

Returns a list of Search::Elasticsearch::Client::Direct object for the appropriate machine and cluster type.

COPYRIGHT

This software is copyright (c) 2019, Anthony Lucas.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.