NAME
Search::Elasticsearch::Client::2_0::Direct::Indices - A client for running index-level requests
VERSION
version 6.81
DESCRIPTION
This module provides methods to make index-level requests, such as creating and deleting indices, managing type mappings, index settings, warmers, index templates and aliases.
It does Search::Elasticsearch::Role::Client::Direct.
INDEX METHODS
create()
$result = $e->indices->create(
index => 'my_index' # required
body => { # optional
index settings
mappings
warmers
}
);
The create()
method is used to create an index. Optionally, index settings, type mappings and index warmers can be added at the same time.
Query string parameters: master_timeout
, timeout
, update_all_types
See the create index docs for more information.
get()
$response = $e->indices->get(
index => 'index' | \@indices # optional
feature => 'feature' | \@features # optional
);
Returns the aliases, settings, mappings, and warmers for the specified indices. The feature
parameter can be set to none or more of: _settings
, _mappings
, _warmers
and _aliases
.
See the get index docs.
Query string parameters: allow_no_indices
, expand_wildcards
, human
, ignore_unavailable
, local
exists()
$bool = $e->indices->exists(
index => 'index' | \@indices # required
);
The exists()
method returns 1
or the empty string to indicate whether the specified index or indices exist.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, local
See the index exists docs for more information.
delete()
$response = $e->indices->delete(
index => 'index' | \@indices # required
);
The delete()
method deletes the specified indices.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, master_timeout
, timeout
See the delete index docs for more information.
close()
$response = $e->indices->close(
index => 'index' | \@indices # required
);
The close()
method closes the specified indices, reducing resource usage but allowing them to be reopened later.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
master_timeout
, timeout
See the close index docs for more information.
open()
$response = $e->indices->open(
index => 'index' | \@indices # required
);
The open()
method opens closed indices.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
master_timeout
, timeout
See the open index docs for more information.
clear_cache()
$response = $e->indices->clear_cache(
index => 'index' | \@indices # optional
);
The clear_cache()
method is used to clear the in-memory filter, fielddata, or id cache for the specified indices.
Query string parameters: allow_no_indices
, expand_wildcards
, fielddata
, fields
, ignore_unavailable
, query
, recycler
, request
See the clear_cache docs for more information.
refresh()
$response = $e->indices->refresh(
index => 'index' | \@indices # optional
);
The refresh()
method refreshes the specified indices (or all indices), allowing recent changes to become visible to search. This process normally happens automatically once every second by default.
Query string parameters: allow_no_indices
, expand_wildcards
, force
, ignore_unavailable
See the refresh index docs for more information.
flush()
$response = $e->indices->flush(
index => 'index' | \@indices # optional
);
The flush()
method causes the specified indices (or all indices) to be written to disk with an fsync
, and clears out the transaction log. This process normally happens automatically.
Query string parameters: allow_no_indices
, expand_wildcards
, force
, ignore_unavailable
, wait_if_ongoing
See the flush index docs for more information.
flush_synced()
$respnse = $e->indices->flush_synced(
index => 'index' | \@indices # optional
);
The flush_synced()
method does a synchronised flush() on the primaries and replicas of all the specified indices. In other words, after flushing it tries to write a sync_id
on the primaries and replicas to mark them as containing the same documents. During recovery, if a replica has the same sync_id
as the primary, then it doesn't need to check whether the segment files on primary and replica are the same, and it can move on directly to just replaying the translog. This can greatly speed up recovery.
Synced flushes happens automatically in the background on indices that have not received any writes for a while, but the flush_synced() method can be used to trigger this process manually, eg before shutting down. Any new commits immediately break the sync.
See the flush synced docs for more information.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
forcemerge()
$response = $e->indices->forcemerge(
index => 'index' | \@indices # optional
);
The forcemerge()
method rewrites all the data in an index into at most max_num_segments
. This is a very heavy operation and should only be run with care, and only on indices that are no longer being updated.
Query string parameters: allow_no_indices
, expand_wildcards
, flush
, ignore_unavailable
, max_num_segments
, only_expunge_deletes
, wait_for_merge
See the forcemerge docs for more information.
optimize()
The optimize()
method is deprecated in 2.x and will be replaced by forcemerge();
$response = $e->indices->optimize(
index => 'index' | \@indices # optional
);
The optimize()
method rewrites all the data in an index into at most max_num_segments
. This is a very heavy operation and should only be run with care, and only on indices that are no longer being updated.
Query string parameters: allow_no_indices
, expand_wildcards
, flush
, ignore_unavailable
, max_num_segments
, only_expunge_deletes
, wait_for_merge
See the optimize index docs for more information.
get_upgrade()
$response = $e->indices->get_upgrade(
index => 'index' | \@indices # optional
);
The get_upgrade()
method returns information about which indices need to be upgraded, which can be done with the upgrade()
method.
Query string parameters: allow_no_indices
, expand_wildcards
, human
, ignore_unavailable
See the upgrade docs for more information.
upgrade()
$response = $e->indices->upgrade(
index => 'index' | \@indices # optional
);
The upgrade()
method upgrades all segments in the specified indices to the latest format.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, only_ancient_segments
, wait_for_completion
See the upgrade docs for more information.
MAPPING METHODS
put_mapping()
$response = $e->indices->put_mapping(
index => 'index' | \@indices # optional,
type => 'type', # required
body => { mapping } # required
)
The put_mapping()
method is used to create or update a type mapping on an existing index. Mapping updates are allowed to add new fields, but not to overwrite or change existing fields.
For instance:
$response = $e->indices->put_mapping(
index => 'users',
type => 'user',
body => {
user => {
properties => {
name => { type => 'string' },
age => { type => 'integer' }
}
}
}
);
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, master_timeout
, timeout
, update_all_types
See the put_mapping docs for more information.
get_mapping()
$result = $e->indices->get_mapping(
index => 'index' | \@indices # optional,
type => 'type' | \@types # optional
);
The get_mapping()
method returns the type definitions for one, more or all types in one, more or all indices.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, local
See the get_mapping docs for more information.
get_field_mapping()
$result = $e->indices->get_field_mapping(
index => 'index' | \@indices # optional,
type => 'type' | \@types # optional,
fields => 'field' | \@fields # required
include_defaults => 0 | 1
);
The get_field_mapping()
method returns the field definitions for one, more or all fields in one, more or all types and indices.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, include_defaults
, local
See the get_mapping docs for more information.
exists_type()
$bool = $e->indices->exists_type(
index => 'index' | \@indices # required,
type => 'type' | \@types # required
);
The exists_type()
method checks for the existence of all specified types in all specified indices, and returns 1
or the empty string.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, local
See the exists_type docs for more information.
ALIAS METHODS
update_aliases()
$response = $e->indices->update_aliases(
body => { actions } # required
);
The update_aliases()
method changes (by adding or removing) multiple index aliases atomically. For instance:
$response = $e->indices->update_aliases(
body => {
actions => [
{ add => { alias => 'current', index => 'logs_2013_09' }},
{ remove => { alias => 'current', index => 'logs_2013_08' }}
]
}
);
Query string parameters: master_timeout
, timeout
See the update_aliases docs for more information.
get_aliases()
$result = $e->indices->get_aliases(
index => 'index' | \@indices, # optional
alias => 'alias' | \@aliases # optional
);
The get_aliases()
method returns a list of aliases per index for all the specified indices.
Query string parameters: local
, timeout
See the get_aliases docs for more information.
put_alias()
$response = $e->indices->put_alias(
index => 'index' | \@indices, # required
name => 'alias', # required
body => { alias defn } # optional
);
The put_alias()
method creates an index alias. For instance:
$response = $e->indices->put_alias(
index => 'my_index',
name => 'twitter',
body => {
filter => { term => { user_id => 'twitter' }}
}
);
Query string parameters: master_timeout
, timeout
See the put_alias docs for more information.
get_alias()
$result = $e->indices->get_alias(
index => 'index' | \@indices, # optional
name => 'alias' | \@aliases # optional
);
The get_alias()
method returns the alias definitions for the specified aliases in the specified indices.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, local
See the get_alias docs for more information.
exists_alias()
$bool = $e->indices->exists_alias(
index => 'index' | \@indices, # optional
name => 'alias' | \@aliases # optional
);
The exists_alias()
method returns 1
or the empty string depending on whether the specified aliases exist in the specified indices.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, local
See the exists_alias docs for more information.
delete_alias()
$response = $e->indices->delete_alias(
index => 'index' | \@indices # required,
name => 'alias' | \@aliases # required
);
The delete_alias()
method deletes one or more aliases from one or more indices.
Query string parameters: master_timeout
, timeout
See the delete_alias docs for more information.
SETTINGS METHODS
put_settings()
$response = $e->indices->put_settings(
index => 'index' | \@indices # optional
body => { settings }
);
The put_settings()
method sets the index settings for the specified indices or all indices. For instance:
$response = $e->indices->put_settings(
body => {
"index.refresh_interval" => -1
}
);
Query string parameters: allow_no_indices
, expand_wildcards
, flat_settings
, ignore_unavailable
, master_timeout
See the put_settings docs for more information.
get_settings()
$result = $e->indices->get_settings(
index => 'index' | \@indices # optional
name => 'name' | \@names # optional
);
The get_settings()
method retrieves the index settings for the specified indices or all indices.
Query string parameters: allow_no_indices
, expand_wildcards
, flat_settings
, human
, ignore_unavailable
, local
See the get_settings docs for more information.
TEMPLATE METHODS
put_template()
$response = $e->indices->put_template(
name => 'template' # required
body => { template defn } # required
);
The put_template()
method is used to create or update index templates.
Query string parameters: create
, flat_settings
, master_timeout
, op_type
, order
, timeout
, version
, version_type
See the put_template docs for more information.
get_template()
$result = $e->indices->get_template(
name => 'template' | \@templates # optional
);
The get_template()
method is used to retrieve a named template.
Query string parameters: flat_settings
, local
, master_timeout
See the get_template docs for more information.
exists_template()
$result = $e->indices->exists_template(
name => 'template' # required
);
The exists_template()
method is used to check whether the named template exists.
Query string parameters: local
, master_timeout
See the get_template docs for more information.
delete_template()
$response = $e->indices->delete_template(
name => 'template' # required
);
The delete_template()
method is used to delete a named template.
Query string parameters: master_timeout
, timeout
, version
, version_type
See the delete_template docs for more information.
WARMER METHODS
put_warmer()
$response = $e->indices->put_warmer(
index => 'index' | \@indices, # optional
type => 'type' | \@types, # optional
name => 'warmer', # required
body => { warmer defn } # required
);
The put_warmer()
method is used to create or update named warmers which are used to warm up new segments in the index before they are exposed to user searches. For instance:
$response = $e->indices->put_warmer(
index => 'my_index',
name => 'date_field_warmer',
body => {
sort => 'date'
}
);
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, master_timeout
, request_cache
See the put_warmer docs for more information.
get_warmer()
$response = $e->indices->get_warmer(
index => 'index' | \@indices, # optional
type => 'type' | \@types, # optional
name => 'warmer' | \@warmers, # optional
);
The get_warmer()
method is used to retrieve warmers by name.
Query string parameters: allow_no_indices
, expand_wildcards
, ignore_unavailable
, local
See the get_warmer docs for more information.
delete_warmer()
$response = $e->indices->get_warmer(
index => 'index' | \@indices, # required
name => 'warmer' | \@warmers, # required
);
The delete_warmer()
method is used to delete warmers by name.
Query string parameters: master_timeout
See the delete_warmer docs for more information.
STATS METHODS
stats()
$result = $e->indices->stats(
index => 'index' | \@indices # optional
metric => 'metric' | \@metrics # optional
);
The stats()
method returns statistical information about one, more or all indices. By default it returns all metrics, but you can limit which metrics are returned by specifying the metric
.
Allowed metrics are: _all
, completion
docs
, fielddata
, filter_cache
, flush
, get
, id_cache
, indexing
, merge
, percolate
, query_cache
, refresh
, request_cache
, search
, segments
, store
, warmer
Query string parameters: completion_fields
, fielddata_fields
, fields
, groups
, human
, level
, types
See the stats docs for more information.
recovery()
$result = $e->indices->recovery(
index => 'index' | \@indices # optional
);
Provides insight into on-going shard recoveries.
Query string parameters: active_only
, detailed
, human
See the recovery docs for more information.
segments()
$result = $e->indices->segments(
index => 'index' | \@indices # optional
);
The segments()
method is used to return information about the segments that an index contains.
Query string parameters: allow_no_indices
, expand_wildcards
, human
, ignore_unavailable
, verbose
See the segments docs for more information.
shard_stores()
$result = $e->indices->shard_stores(
index => 'index' | \@indices # optional
);
The shard_stores()
method is used to find out which nodes contain copies of which shards, whether the shards are allocated or not.
Query string parameters: allow_no_indices
, expand_wildcards
, human
, ignore_unavailable
, status
See the shard_stores docs for more information.
QUERY AND ANALYSIS METHODS
analyze()
$result = $e->indices->analyze(
index => 'index' # optional,
body => 'text to analyze'
);
The analyze()
method passes the text in the body
through the specified analyzer
, tokenizer
or token filter
- which may be global, or associated with a particular index or field - and returns the tokens. Very useful for debugging analyzer configurations.
Query string parameters: analyzer
, attributes
, char_filter
, explain
, field
, filter
, format
, prefer_local
, text
, tokenizer
See the analyze docs for more information.
validate_query()
$result = $e->indices->validate_query(
index => 'index' | \@indices, # optional
type => 'type' | \@types, # optional
body => { query }
);
The validate_query()
method accepts a query in the body
and checks whether the query is valid or not. Most useful when explain
is set to true
, in which case it includes an execution plan in the output.
Query string parameters: allow_no_indices
, analyze_wildcard
, analyzer
, default_operator
, df
, explain
, expand_wildcards
, ignore_unavailable
, lenient
, lowercase_expanded_terms
q
, rewrite
See the validate_query docs for more information.
AUTHOR
Enrico Zimuel <enrico.zimuel@elastic.co>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2020 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004