Elastic-Model
view release on metacpan or search on metacpan
lib/Elastic/Model/Role/Index.pm view on Meta::CPAN
sub _index_action {
#===================================
my $self = shift;
my $action = shift;
my %args = @_;
$self->model->store->$action( %args, index => $self->name );
return $self;
}
#===================================
sub update_settings {
#===================================
my $self = shift;
$self->model->store->update_index_settings(
index => $self->name,
settings => {@_}
);
return $self;
}
#===================================
sub update_analyzers {
#===================================
my $self = shift;
my $params = $self->index_config(@_);
delete $params->{mappings};
$self->model->store->update_index_settings(%$params);
return $self;
}
#===================================
sub is_alias {
lib/Elastic/Model/Role/Index.pm view on Meta::CPAN
#===================================
sub is_index {
#===================================
my $self = shift;
my $name = $self->name;
my $indices = $self->model->store->get_aliases( index => $name );
return !!$indices->{$name};
}
#===================================
sub update_mapping {
#===================================
my $self = shift;
my %args = ref $_[-1] eq 'HASH' ? %{ pop() } : ();
my $mappings = $self->mappings(@_);
my $store = $self->model->store;
my $name = $self->name;
for my $type ( keys %$mappings ) {
$store->put_mapping(
index => $name,
type => $type,
lib/Elastic/Model/Role/Store.pm view on Meta::CPAN
#===================================
sub close_index {
#===================================
my $self = shift;
my %args = _cleanup(@_);
return $self->es->indices->close(%args);
}
#===================================
sub update_index_settings {
#===================================
my ( $self, %args ) = @_;
$args{body} = { settings => delete $args{settings} };
return $self->es->indices->put_settings(%args);
}
#===================================
sub get_aliases {
#===================================
my $self = shift;
lib/Elastic/Model/UID.pm view on Meta::CPAN
my %params = %{ shift() };
$class->new(
from_store => 1,
is_partial => 1,
routing => $params{fields}{_routing},
map { $_ => $params{"_$_"} } qw(index type id version)
);
}
#===================================
sub update_from_store {
#===================================
my $self = shift;
my $params = shift;
$self->$_( $params->{$_} ) for qw(_index _id _version);
$self->_from_store(1);
$self->_clear_cache_key;
$self;
}
#===================================
sub update_from_uid {
#===================================
my $self = shift;
my $uid = shift;
$self->_index( $uid->index );
$self->_routing( $uid->routing );
$self->_version( $uid->version );
$self->_from_store(1);
$self->_clear_cache_key;
$self;
}
( run in 1.036 second using v1.01-cache-2.11-cpan-49f99fa48dc )