Elastic::Model::Role::Index - Provides admin methods common to indices and aliases
version 0.52
$admin->close(); $admin->open(); $admin->delete(); $admin->refresh(); $admin->update_mapping(@types); $admin->delete_mapping(@types); $admin->update_analyzers(); $admin->update_settings(%settings); $bool = $admin->is_alias; $bool = $admin->is_index; $bool = $admin->exists;
Elastic::Model::Role::Index is a role which provides admin methods common to indices and aliases. It is consumed by Elastic::Model::Index and Elastic::Model::Alias.
See Elastic::Manual::Scaling for more about how domains, indices and aliases relate to each other.
$name = $admin->name;
The name of the index or alias to be administered. This defaults to the name of the "namespace" but can be overridden when creating a new Elastic::Model::Index or Elastic::Model::Alias object, eg:
$index = $namesapace->index('index_name')
The Elastic::Model::Namespace object used to create the Elastic::Model::Index or Elastic::Model::Alias object.
The same Search::Elasticsearch connection as "es" in Elastic::Model::Role::Model.
$admin = $admin->delete(); $admin = $admin->delete( %args );
Deletes the index (or indices pointed to by alias ) "name". Any %args are passed directly to "delete()" in Search::Elasticsearch::Client::Direct::Indices. For example:
%args
$admin->delete( ignore => 404 );
$admin = $admin->refresh();
Forces the the index (or indices pointed to by alias ) "name" to be refreshed, ie all changes to the docs in the index become visible to search. By default, indices are refreshed once every second anyway. You shouldn't abuse this option as it will have a performance impact.
$admin = $admin->open();
Opens the index (or the SINGLE index pointed to by alias ) "name".
$admin = $admin->close();
Closes the index (or the SINGLE index pointed to by alias ) "name".
$config = $admin->index_config( settings=> \%settings, types=> \@types );
Returns a hashref containing the index/alias "name", the settings, and the mappings for the current namespace. The generated analysis settings are merged into any %settings that you provide. Mappings and analysis settings will be for all @types known to the "namespace" unless specified.
%settings
@types
This method is used by "update_analyzers()" and "create_index()" in Elastic::Model::Index.
$admin = $admin->update_settings( %settings );
Updates the index settings for the the index (or indices pointed to by alias ) "name".
For example, if you want to rebuild an index, you could disable refresh until you are finished indexing:
$admin->update_settings( refresh_interval => -1 ); populate_index(); $admin->update_settings( refresh_interval => '1s' );
$admin = $admin->update_analyzers( types => \@types );
Mostly, analyzers can't be changed on an existing index, but new analyzers can be added. "update_analyzers()" will generate a new analyzer configuration and try to update index (or the indices pointed to by alias) "name".
You can limit the analyzers to those required for a specific list of @types, otherwise it calculates the analyzer configuration for all types known to the "namespace".
$admin = $admin->update_mapping(); $admin = $admin->update_mapping( @type_names ); $admin = $admin->update_mapping( @type_names, { ignore_conflicts=> 1 } );
Type mappings cannot be changed on an existing index, but they can be added to. "update_mapping()" will generate a new type mapping from your doc classes, and try to update index (or the indices pointed to by alias) "name".
You can optionally specify a list of types to update, otherwise it will update all types known to the "namespace".
$admin->update_mapping( 'user','post');
Any optional args passed as a hashref as the final parameter will be passed to "put_mapping()" in Search::Elasticsearch::Client::Direct::Indices
$admin = $admin->delete_mapping( @types ); $admin = $admin->delete_mapping( @types, { ignore => 404 });
Deletes the type mapping AND THE DOCUMENTS for the listed types in the index (or the indices pointed to by alias) "name". Any optional args passed as a hashref as the final parameter will be passed to "delete_mapping()" in Search::Elasticsearch::Client::Direct::Indices.
$bool = $admin->exists();
Checks whether the index (or ALL the indices pointed to by alias ) "name" exist.
$bool = $admin->is_alias();
Returns true if "name" is an alias.
$bool = $admin->is_index();
Returns true if "name" is an index.
Elastic::Model::Index
Elastic::Model::Alias
Elastic::Model::Namespace
Elastic::Manual::Scaling
Clinton Gormley <drtech@cpan.org>
This software is copyright (c) 2015 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.
To install Elastic::Model, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Elastic::Model
CPAN shell
perl -MCPAN -e shell install Elastic::Model
For more information on module installation, please visit the detailed CPAN module installation guide.