Search...Indices(3pm)
π Search...Indices(3pm) β User Contributed Perl Documentation π
okay bestie, buckle UP, because this is Search::Elasticsearch::Client::8_0::Direct::Indices and it's literally the index-level boss of the whole Perl Elasticsearch client. this is part 1 of 3 so don't go anywhere, we're just getting started π«Ά
β¨ NAME β¨
Search::Elasticsearch::Client::8_0::Direct::Indices β a client for running index-level requests. that's it, that's the whole vibe. no cap. π
πΈ VERSION πΈ
version 8.12 β¨ (yes queen, we're on 8.12)
π¦ DESCRIPTION π¦
so like, this module hands you the methods to make index-level requests β think creating and deleting indices, managing type mappings, index settings, index templates and aliases. all the admin-y stuff. the backstage pass of your cluster. π
It does Search::Elasticsearch::Role::Client::Direct. periodt.
π INDEX METHODS π
π create()
$result = $e->indices->create(
index => 'my_index' # required
body => { # optional
index settings
mappings
aliases
}
);
The create() method is used to create an index. and the cute part? you can optionally slap on index settings, type mappings, and aliases at the same time. build-a-bear but it's a search index π§Έ
Query string parameters:
error_tracehumaninclude_type_namemaster_timeouttimeoutupdate_all_typeswait_for_active_shards
See the create index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html for more information.
π get()
$response = $e->indices->get(
index => 'index' | \@indices # required
);
Returns the aliases, settings, and mappings for the specified indices. it's giving "tell me everything about yourself" energy π
See the get index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html.
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardsflat_settingshumanignore_unavailableinclude_defaultsinclude_type_namelocalmaster_timeout
π 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. are you there or are you not. main character or ghosted. π»
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardsflat_settingshumanignore_unavailableinclude_defaultslocal
See the index exists docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-indices-exists.html for more information.
π delete()
$response = $e->indices->delete(
index => 'index' | \@indices # required
);
The delete() method deletes the specified indices. gone. erased. no thoughts head empty π
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardshumanignore_unavailablemaster_timeouttimeout
See the delete index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-index.html for more information.
π close()
$response = $e->indices->close(
index => 'index' | \@indices # required
);
The close() method closes the specified indices β that means less resource usage, but they're still able to be reopened later. it's a nap, not a funeral. π΄
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardshumanignore_unavailablemaster_timeouttimeout
See the close index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html for more information.
π open()
$response = $e->indices->open(
index => 'index' | \@indices # required
);
The open() method opens closed indices. wake up bestie, the nap is over βοΈ
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardshumanignore_unavailablemaster_timeouttimeoutwait_for_active_shards
See the open index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html for more information.
π rollover()
$response = $e->indices->rollover(
alias => $alias, # required
new_index => $index, # optional
body => { rollover conditions } # optional
);
Rollover an index pointed to by alias if it meets rollover conditions (eg max age, max docs) to a new index name. out with the old, in with the new β¨
Query string parameters:
dry_runerror_tracehumaninclude_type_namemaster_timeouttimeoutwait_for_active_shards
See the rollover index docs at https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-rollover-index.html for more information.
π shrink()
$response = $e->shrink(
index => $index, # required
target => $target, # required
body => { mappings, settings aliases } # optional
);
The shrink API shrinks the shards of an index down to a single shard (or to a factor of the original shards). glow-down, but make it storage π
Query string parameters:
copy_settingserror_tracefilter_pathhumanmaster_timeouttimeoutwait_for_active_shards
See the shrink index docs at https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shrink-index.html for more information.
π split()
$response = $e->split(
index => $index, # required
target => $target, # required
);
The split API splits a shard into multiple shards. opposite of shrink, it's the glow-UP π
Query string parameters:
copy_settingserror_tracefilter_pathhumanmaster_timeouttimeoutwait_for_active_shards
See the split index docs at https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-split-index.html for more information.
π freeze()
$response = $e->indices->freeze(
$index => $index # required
);
The freeze() API is used to freeze an index, which puts it in a state which has almost no overhead on the cluster. ice queen behaviour βοΈπ
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardsfilter_pathhumanignore_unavailablemaster_timeouttimeoutwait_for_active_shards
See the freeze index docs at https://www.elastic.co/guide/en/elasticsearch/reference/current/freeze-index-api.html for more information.
π unfreeze()
$response = $e->indices->unfreeze(
$index => $index # required
);
The unfreeze() API is used to return a frozen index to its normal state. thawing out, we love a comeback arc π₯
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardsfilter_pathhumanignore_unavailablemaster_timeouttimeoutwait_for_active_shards
See the unfreeze index docs at https://www.elastic.co/guide/en/elasticsearch/reference/current/freeze-index-api.html 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. spring cleaning, but for RAM π§Ήβ¨
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardsfielddatafieldshumanignore_unavailablequeryrequest
See the clear_cache docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-clearcache.html 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. so like, it's the auto-refresh of your feed, but for search results π
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardshumanignore_unavailable
See the refresh index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-refresh.html 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. committing your work to disk, the responsible queen move πΎ
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardsforcehumanignore_unavailablewait_if_ongoing
See the flush index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-flush.html 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.
okay that was a lot, let me say it cuter: it's matching friendship bracelets so the primary and replica can skip the whole "are we the same tho?" interrogation and jump straight to the translog replay. faster recovery, less drama π«Ά
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 at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-synced-flush.html for more information.
Query string parameters:
allow_no_indiceserror_traceexpand_wildcardshumanignore_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.
bestie listen. very heavy operation. be careful. only run it on indices that are no longer being updated. do NOT just yolo this on your live write index, I'm begging π
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""flush""human""ignore_unavailable""max_num_segments""only_expunge_deletes"
See the forcemerge docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html for more information.
get_upgrade() β¨
$response = $e->indices->get_upgrade(
index => 'index' | \@indices # optional
);
Okay so get_upgrade() is the one that tells you which indices are like βbestie we need an upgradeβ β it returns info about which indices need to be upgraded, and you can actually do the upgrade with the upgrade() method. π
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""human""ignore_unavailable"
See the upgrade docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html 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. Itβs giving glow-up for your segments, periodt. β¨
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""human""ignore_unavailable""only_ancient_segments""wait_for_completion"
See the upgrade docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html for more information.
MAPPING METHODS πΊοΈ
put_mapping()
$response = $e->indices->put_mapping(
index => 'index' | \@indices # optional,
type => 'type', # optional
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. So you can add new stuff, but donβt even think about touching the existing fields, bestie. π
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""error_trace""expand_wildcards""human""ignore_unavailable""include_type_name""master_timeout""timeout""update_all_types"
See the put_mapping docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html 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. Itβs like the receipts for your mappings, iykyk. π§Ύ
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""human""ignore_unavailable""include_type_name""local""master_timeout"
See the get_mapping docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html 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. Yes, itβs that specific. π
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""human""ignore_unavailable""include_defaults""include_type_name""local"
See the get_mapping docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html 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. So itβs a yes/no vibe check. π
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""human""ignore_unavailable""local"
See the exists_type docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html 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' }}
]
}
);
Atomic means all or nothing, bestie. No half-done chaos. β¨
Query string parameters:
"error_trace""human""master_timeout""timeout"
See the update_aliases docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html 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' }}
}
);
Itβs giving nickname energy for your index. π
Query string parameters:
"error_trace""human""master_timeout""timeout"
See the put_alias docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html 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. Basically, it shows you the alias lore. π
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""human""ignore_unavailable""local"
See the get_alias docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html for more information.
exists_alias() β
$bool = $e->indices->exists_alias(
index => 'index' | \@indices, # optional
name => 'alias' | \@aliases # required
);
The exists_alias() method returns 1 or the empty string depending on whether the specified aliases exist in the specified indices. Yes/no, no cap. π«Ά
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""human""ignore_unavailable""local"
See the exists_alias docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html 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. Bye bye, alias. π
Query string parameters:
"error_trace""human""master_timeout""timeout"
See the delete_alias docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html 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""error_trace""expand_wildcards""flat_settings""human""ignore_unavailable""master_timeout""preserve_existing""timeout"
See the put_settings docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html 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. Itβs the settings receipts, bestie. π§Ύ
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""flat_settings""human""ignore_unavailable""include_defaults""local""master_timeout"
See the get_settings docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html for more information.
β¨ TEMPLATE METHODS β¨
Okay bestie, templates are like the blueprint vibes for your indices, and these methods are how you handle them. Let's go. π
π οΈ put_template()
$response = $e->indices->put_template(
name => 'template' # required
body => { template defn } # required
);
The put_template() method is your main character move for creating or updating index templates. Slay.
Query string parameters:
"create""error_trace""flat_settings""human""include_type_name""master_timeout""order""timeout"
See the put_template docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html 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. It's giving "where's my template at?"
Query string parameters:
"error_trace""flat_settings""human""include_type_name""local""master_timeout"
See the get_template docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html for more information.
π΅οΈ exists_template()
$result = $e->indices->exists_template(
name => 'template' # optional
);
The exists_template() method is used to check whether the named template exists. Vibe check: does it exist or not?
Query string parameters:
"error_trace""flat_settings""human""local""master_timeout"
See the get_template docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html for more information.
ποΈ delete_template()
$response = $e->indices->delete_template(
name => 'template' # required
);
The delete_template() method is used to delete a named template. Bye bestie! π
Query string parameters:
"error_trace""human""master_timeout""timeout""version""version_type"
See the delete_template docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html for more information.
π STATS METHODS π
Now we're getting into the numbers, the receipts, the statistical tea. β
π 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"
Query string parameters:
"completion_fields""error_trace""fielddata_fields""fields""groups""human""include_segment_file_sizes""level""types"
See the stats docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html for more information.
π©Ί recovery()
$result = $e->indices->recovery(
index => 'index' | \@indices # optional
);
Provides insight into on-going shard recoveries. Like a little health check for your shards.
Query string parameters:
"active_only""detailed""error_trace""human"
See the recovery docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html 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. Segment tea, spilled.
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""human""ignore_unavailable""verbose"
See the segments docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-segments.html 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. It's giving "who has my shards?" energy.
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""human""ignore_unavailable""status"
See the shard_stores docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shards-stores.html for more information.
π QUERY AND ANALYSIS METHODS π
Time to analyze, validate, and generally be the main character of your data. β¨
π¬ 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. Literally the debugger bestie you need.
Query string parameters:
"error_trace""human"
See the analyze docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html 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. No cap, this one saves you from embarrassing query fails.
Query string parameters:
"all_shards""allow_no_indices""analyze_wildcard""analyzer""default_operator""df""error_trace""explain""expand_wildcards""ignore_unavailable""lenient""q""rewrite"
See the validate_query docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-validate.html for more information.
π AUTHOR π
Enrico Zimuel <enrico.zimuel@elastic.co>
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2024 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
And that's a wrap, bestie! This page came from perl v5.38.2, dated 2024-02-04, and it's the Search...Indices(3pm) manual. Stay iconic, keep your indices slaying, and may your queries always validate on the first try. πβ¨
π¦ where this page comes from
- debian trixie: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu noble: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu resolute: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu stonking: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms