App-ElasticSearch-Utilities
view release on metacpan or search on metacpan
README.mkdn view on Meta::CPAN
## es\_optimize\_index('index-name')
Optimize an index to a single segment per shard
## es\_apply\_index\_settings('index-name', { settings })
Apply a HASH of settings to an index.
# FORMAT FUNCTIONS
## 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",
## 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',
## es\_format\_numeric
Takes a value and the minimum digits of significance.
# FUNCTIONS
## 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.
## es\_pattern
Returns a hashref of the pattern filter used to get the indexes
{
string => '\*',
re => '.\*',
}
## es\_master(\[$handle\])
Returns true (1) if the handle is to the the cluster master, or false (0) otherwise.
## es\_nodes
Returns the hash of index meta data.
## 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:
- **state**
Default is 'open', can be used to find 'closed' indexes as well.
- **check\_state**
Default is 1, set to 0 to disable state checks. The combination of the default
with this option and the default for **state** means only open indices are returned.
- **check\_dates**
Default is 1, set to 0 to disable checking index age.
## es\_segment\_stats($index)
Return the number of shards and segments in an index as a hashref
## es\_settings()
Exposes GET /\_settings
Returns a hashref
## es\_node\_stats()
Exposes GET /\_nodes/stats
Returns a hashref
## es\_flatten\_hash
Performs flattening that's compatible with Elasticsearch's flattening.
## def('key')
Exposes Definitions grabbed by options parsing
## es\_local\_index\_meta(key => 'base' || 'index')
Fetch meta-data from the local config file, i.e. `~/.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
it's date, and then on through all the bases discovered with
`es_index_bases()`.
This is used by the `es-search.pl` utility to do lookups of the **timestamp**
( run in 1.281 second using v1.01-cache-2.11-cpan-c966e8aa7e8 )