NAME
Elastic::Model::Role::Index - Provides admin methods common to indices and aliases
VERSION
version 0.06
SYNOPSIS
$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;
DESCRIPTION
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.
ATTRIBUTES
name
$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')
namespace
The Elastic::Model::Namespace object used to create the Elastic::Model::Index or Elastic::Model::Alias object.
es
The same ElasticSearch connection as "es" in Elastic::Model::Role::Model.
METHODS
delete()
$admin = $admin->delete();
$admin = $admin->delete( %args );
Deletes the index (or indices pointed to by alias ) "name". Any %args
are passed directly to "delete_index()" in ElasticSearch. For example:
$admin->delete( ignore_missing => 1 );
refresh()
$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.
open()
$admin = $admin->open();
Opens the index (or the SINGLE index pointed to by alias ) "name".
close()
$admin = $admin->close();
Closes the index (or the SINGLE index pointed to by alias ) "name".
index_config()
$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.
This method is used by "update_analyzers()" and "create_index()" in Elastic::Model::Index.
update_settings()
$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' );
update_analyzers()
$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".
update_mapping()
$admin = $admin->update_mapping();
$admin = $admin->update_mapping( @type_names );
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');
delete_mapping();
$admin = $admin->delete_mapping( @types );
Deletes the type mapping AND THE DOCUMENTS for the listed types in the index (or the indices pointed to by alias) "name".
exists()
$bool = $admin->exists();
Checks whether the index (or ALL the indices pointed to by alias ) "name" exist.
is_alias()
$bool = $admin->is_alias();
Returns true if "name" is an alias.
is_index()
$bool = $admin->is_index();
Returns true if "name" is an index.
SEE ALSO
AUTHOR
Clinton Gormley <drtech@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 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.