Permalink
Browse files

Added all_live_indices() to Namespace and Model

  • Loading branch information...
clintongormley committed Jul 7, 2012
1 parent e2e1576 commit 8e4010b7c3ad6587168273084dd6ba9173dd626b
Showing with 29 additions and 2 deletions.
  1. +15 −0 lib/Elastic/Model/Namespace.pm
  2. +14 −2 lib/Elastic/Model/Role/Model.pm
@@ -50,6 +50,15 @@ sub all_domains {
return uniq @domains;
}
#===================================
sub all_live_indices {
#===================================
my $self = shift;
my @domains = ( $self->name, @{ $self->fixed_domains } );
my $aliases = $self->model->es->get_aliases( index => \@domains );
return keys %$aliases;
}
#===================================
sub index {
#===================================
@@ -229,6 +238,12 @@ Returns all domain names known to the namespace. It does this by retrieving
all indices and aliases associated with the namespace L</name> and the
L</fixed_domains> (if any).
=head2 all_live_indices()
@indices = $namespace->all_live_indices();
Queries ElasticSearch to find all existing indices related to the namespace
=head2 mappings()
\%mapping = $namespace->mappings();
@@ -190,6 +190,13 @@ sub namespace_for_domain {
or croak "No namespace found for domain ($domain). ";
}
#===================================
sub all_live_indices {
#===================================
my $self = shift;
return map { $_->all_live_indices } values %{ $self->namespaces };
}
#===================================
sub wrap_doc_class {
#===================================
@@ -547,8 +554,6 @@ L<Elastic::Model::View/"new()">.
Use a C<$view> to query your documents. Views can be multi-domain and
multi-type.
=head2 new_scope()
$scope = $model->new_scope();
@@ -667,6 +672,13 @@ Returns the L<Elastic::Model::Namespace> object which corresponds to the
C<$domain_name>. If the index (or alias) name is not yet known to the
C<$model>, it will update the known domain list from the namespace objects.
=head3 all_live_indices()
@indices = $model->all_live_indices();
Queries ElasticSearch to find all existing indices related to all namespaces
known to the model.
=head3 es
$es = $model->es

0 comments on commit 8e4010b

Please sign in to comment.