The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Elastic::Model::Alias - Administer aliases in Elasticsearch

VERSION

version 0.27

SYNOPSIS

    $alias = $model->namespace('myapp')->alias;
    $alias = $model->namespace('myapp')->alias('alias_name');

    $alias->to( 'index_1', 'index_2' );
    $alias->to( 'index_1' => \%settings, index_2 => \%settings);

    $alias->add( 'index_1', 'index_2' );
    $alias->add( 'index_1' => \%settings, index_2 => \%settings);

    $alias->remove( 'index_1', 'index_2' );

    \%indices = $alias->aliased_to;

See also "SYNOPSIS" in Elastic::Model::Role::Index.

DESCRIPTION

Elastic::Model::Alias objects are used to create and administer index aliases in an Elasticsearch cluster.

See Elastic::Model::Role::Index for more about usage. See Elastic::Manual::Scaling for more about how aliases can be used in your application.

METHODS

to()

    $alias = $alias->to(@index_names);
    $alias = $alias->to(
        index_name => \%alias_settings,
        ...
    );

Creates or updates the alias "name" and sets it to point to the listed indices. If it already exists and points to indices not specified in @index_names, then those indices will be removed from the alias.

You can delete an alias completely with:

    $alias->to();

Aliases can have filters and routing values associated with an index, for instance:

    $alias->to(
        my_index => {
            routing => 'client_one',
            filterb => { client => 'client_one'}
        }
    );

See Elastic::Manual::Scaling for more about these options.

add()

    $alias = $alias->add(@index_names);
    $alias = $alias->add(
        index_name => \%alias_settings,
        ...
    );

"add()" works in the same way as "to()" except that indices are only added - existing indices are not removed.

remove()

    $alias = $alias->remove(@index_names);

The listed index names are removed from alias "name".

aliased_to()

    $indices = $alias->aliased_to();

Returns a hashref of the current settings for an alias, suitable for passing to "to()". The keys are index names, and the values are the alias settings.

IMPORTED ATTRIBUTES

Attributes imported from Elastic::Model::Role::Index

namespace

name

IMPORTED METHODS

Methods imported from Elastic::Model::Role::Index

close()

open()

refresh()

delete()

update_analyzers()

update_settings()

delete_mapping()

is_alias()

is_index()

SEE ALSO

AUTHOR

Clinton Gormley <drtech@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Clinton Gormley.

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