App-ElasticSearch-Utilities
view release on metacpan or search on metacpan
lib/App/ElasticSearch/Utilities.pm view on Meta::CPAN
=head2 es_optimize_index('index-name')
Optimize an index to a single segment per shard
=head2 es_apply_index_settings('index-name', { settings })
Apply a HASH of settings to an index.
=head1 FORMAT FUNCTIONS
=head2 es_human_count
Takes a number and returns the number as a string in docs, thousands, millions, or billions.
1_000 -> "1.00 thousand",
1_000_000 -> "1.00 million",
=head2 es_human_size
Takes a number and returns the number as a string in bytes, Kb, Mb, Gb, or Tb using base 1024.
1024 -> '1.00 Kb',
1048576 -> '1.00 Mb',
1073741824 -> '1.00 Gb',
=head2 es_format_numeric
Takes a value and the minimum digits of significance.
=head1 FUNCTIONS
=head2 es_pass_exec(host, username)
Called from es_basic_auth to exec a program, capture the password
and return it to the caller. This allows the use of password vaults
and keychains.
=head2 es_pattern
Returns a hashref of the pattern filter used to get the indexes
{
string => '*',
re => '.*',
}
=head2 es_master([$handle])
Returns true (1) if the handle is to the the cluster master, or false (0) otherwise.
=head2 es_nodes
Returns the hash of index meta data.
=head2 es_indices
Returns a list of active indexes matching the filter criteria specified on the command
line. Can handle indices named:
logstash-YYYY.MM.DD
dcid-logstash-YYYY.MM.DD
logstash-dcid-YYYY.MM.DD
logstash-YYYY.MM.DD-dcid
Makes use of --datesep to determine where the date is.
Options include:
=over 4
=item B<state>
Default is 'open', can be used to find 'closed' indexes as well.
=item B<check_state>
Default is 1, set to 0 to disable state checks. The combination of the default
with this option and the default for B<state> means only open indices are returned.
=item B<check_dates>
Default is 1, set to 0 to disable checking index age.
=back
=head2 es_segment_stats($index)
Return the number of shards and segments in an index as a hashref
=head2 es_settings()
Exposes GET /_settings
Returns a hashref
=head2 es_node_stats()
Exposes GET /_nodes/stats
Returns a hashref
=head2 es_flatten_hash
Performs flattening that's compatible with Elasticsearch's flattening.
=head2 def('key')
Exposes Definitions grabbed by options parsing
=head2 es_local_index_meta(key => 'base' || 'index')
Fetch meta-data from the local config file, i.e. C<~/.es-utils.yaml>.
Format is:
---
meta:
index_name:
key: value
index_basename:
key: value
The most specific version is searched first, followed by the index stripped of
( run in 1.834 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )