Search...Indices(3pm)
π Search...Indices(3pm) β User Contributed Perl Documentation π
okay bestie, gather round, because this is Search...Indices(3pm) and it's about to be your new fave. It lives in the User Contributed Perl Documentation crew and it's fr fr iconic.
β¨ NAME β¨
Search::Elasticsearch::Client::1_0::Direct::Indices β a client for running index-level requests π
πΈ VERSION πΈ
version 6.81
π¦ DESCRIPTION π¦
This module hands you the methods for making index-level requests, like creating and deleting indices, managing type mappings, index settings, warmers, index templates and aliases. The whole vibe is "index admin, but make it cute."
It does Search::Elasticsearch::Role::Client::Direct. Periodt. π
π INDEX METHODS π
π create()
$result = $e->indices->create(
index => 'my_index' # required
body => { # optional
index settings
mappings
warmers
}
);
The create() method is the method for creating an index. And the slay part? You can optionally pile on index settings, type mappings and index warmers at the exact same time. Two birds, one gorgeous index. ποΈ
Query string parameters:
master_timeouttimeout
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 # 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. Mix and match, bestie. π
See the get index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html.
Query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailablelocal
π exists()
$bool = $e->indices->exists(
index => 'index' | \@indices # required
);
The exists() method returns 1 or the empty string, to tell you whether the specified index or indices exist. Yes, a boolean that isn't really a boolean. That's just the lore. π
Query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailablelocal
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. Poof. π¦
Query string parameters:
allow_no_indicesexpand_wildcardsignore_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. It lowers the resource usage but keeps them reopenable later, so it's less "goodbye" and more "brb". π΄
Query string parameters:
allow_no_indicesexpand_wildcardsignore_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. The brb is over, she's back. β¨
Query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailablemaster_timeouttimeout
See the open index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-open-close.html for more information.
π clear_cache()
$response = $e->indices->clear_cache(
index => 'index' | \@indices # optional
);
The clear_cache() method clears the in-memory filter, fielddata, or id cache for the specified indices. It's giving "spring cleaning but for RAM". π§Ήπ§
Query string parameters:
allow_no_indicesexpand_wildcardsfielddatafieldsfilterfilter_cachefilter_keysidid_cacheignore_unavailablequery_cacherecycler
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), which lets recent changes become visible to search. Ngl, this process normally happens automatically once every second by default β so it's already doing the work, she's just doing it quietly. β
Query string parameters:
allow_no_indicesexpand_wildcardsforceignore_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 makes the specified indices (or all indices) get written to disk with an fsync, and it clears out the transaction log. This process normally happens automatically, so no, you don't have to micromanage her. π
Query string parameters:
allow_no_indicesexpand_wildcardsforcefullignore_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
);
(yes bestie, that's literally how it's spelled up there β we keep it exactly as-is, no editing the source, that's the rule π )
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. She said "skip the paperwork, I know her." πββοΈπ¨
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/flush.html for more information.
π optimize()
$response = $e->indices->optimize(
index => 'index' | \@indices # optional
);
The optimize() method rewrites all the data in an index into at most max_num_segments.
β οΈ real talk: this is a very heavy operation and should only be run with care, and only on indices that are no longer being updated. Do not casually hit this on a live index, bestie, I am begging. π
Query string parameters:
allow_no_indicesexpand_wildcardsflushignore_unavailablemax_num_segmentsonly_expunge_deleteswait_for_merge
See the optimize index docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-optimize.html for more information.
π get_upgrade()
$response = $e->indices->get_upgrade(
index => 'index' | \@indices # optional
);
The get_upgrade() method returns info about which indices need to be upgraded β which, btw, can be done with the upgrade() method. It's the vibe check before the glow-up. π
Query string parameters:
allow_no_indicesexpand_wildcardshumanignore_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. The actual glow-up. π
Query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailableonly_ancient_segmentswait_for_completion
See the upgrade docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html for more information.
πΈ MAPPING METHODS πΈ
Bestie, this whole section is about mappings β aka the blueprint that tells Elasticsearch what shape your fields are. Think of it like the vibes document for your data. π
π put_mapping()
$response = $e->indices->put_mapping(
index => 'index' | \@indices # optional,
type => 'type', # required
body => { mapping } # required
)
Okay so put_mapping() is your girl for making a whole new type mapping, or updating one that already lives on an existing index. β¨ Here's the tea though: mapping updates can add new fields, but they absolutely cannot overwrite or change fields that are already there. Not negotiable, no take-backs. π
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_indicesexpand_wildcardsignore_unavailableignore_conflictsmaster_timeouttimeout
See the put_mapping docs <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
);
get_mapping() hands you back the type definitions β for one type, a bunch of types, or literally all of them, across one index or many. It's giving "show me everything" energy and we love that. π
Query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailablelocal
See the get_mapping docs <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,
field => 'field' | \@fields # required
include_defaults => 0 | 1
);
Want the field-level deets? get_field_mapping() returns the field definitions for one field, several fields, or all of them β across one type, several types, one index, or many. So many combos, so little time. π¦
Query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailableinclude_defaultslocal
See the get_mapping docs <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
);
exists_type() does a lil vibe check β¨ β it looks at all the types you named across all the indices you named and returns 1 or the empty string. Does it exist or nah? That's the whole story.
Query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailablelocal
See the exists_type docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html> for more information. π
π delete_mapping()
$response = $e->indices->delete_mapping(
index => 'index' | \@indices # required,
type => 'type' | \@types # required
);
π¨ Bestie, read this twice: delete_mapping() deletes the type mappings and all documents of that type in all the specified indices. That's not a soft delete, that's gone gone. π
Query string parameters:
master_timeout
See the delete_mapping docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-delete-mapping.html> for more information. π
π ALIAS METHODS π
Aliases are the nicknames your indices get to have β so your app can hit current and not care which actual index that is this month. Iconic behaviour. π
π update_aliases()
$response = $e->indices->update_aliases(
body => { actions } # required
);
update_aliases() adds and removes a whole bunch of index aliases atomically β so it's all-or-nothing, no half-finished chaos. 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_timeouttimeout
See the update_aliases docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html> for more information. π
π get_aliases()
$result = $e->indices->get_aliases(
index => 'index' | \@indices, # optional
alias => 'alias' | \@aliases # optional
);
get_aliases() returns a list of aliases per index, for all the indices you asked about. Cute lil per-index breakdown, we stan. π
Query string parameters:
localtimeout
See the get_aliases docs <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
);
put_alias() 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_timeouttimeout
See the put_alias docs <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
);
get_alias() returns the alias definitions for the aliases you name, inside the indices you name. Not just "does it exist" β the full definition. β¨
Query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailablelocal
See the get_alias docs <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 # optional
);
exists_alias() returns 1 or the empty string, depending on whether the aliases you named exist in the indices you named. Simple. Clean. Slay. π
Query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailablelocal
See the exists_alias docs <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
);
delete_alias() deletes one or more aliases from one or more indices. That's it, that's the whole thing. π«Ά
Query string parameters:
master_timeouttimeout
See the delete_alias docs <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 }
);
put_settings() sets the index settings for the indices you pick β or for all indices if you don't pick any. For instance:
$response = $e->indices->put_settings(
body => {
"index.refresh_interval" => -1
}
);
Query string parameters:
allow_no_indicesexpand_wildcardsflat_settingsignore_unavailablemaster_timeout
See the put_settings docs <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
);
get_settings() retrieves the index settings for the indices you name, or for all indices. Give me the config, bestie. π
Query string parameters:
allow_no_indicesexpand_wildcardsflat_settingsignore_unavailablelocal
See the get_settings docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html> for more information. π
π§ TEMPLATE METHODS π§
Templates are the pre-set fits your new indices get to wear. So organized of them. π
π§ put_template()
$response = $e->indices->put_template(
name => 'template' # required
body => { template defn } # required
);
put_template() is used to create or update index templates. β¨
Query string parameters:
createflat_settingsmaster_timeoutop_typeordertimeoutversionversion_type
See the put_template docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html> for more information. π
π§ get_template()
$result = $e->indices->get_template(
name => 'template' # optional
);
get_template() is used to retrieve a named template. Just the one you ask for. π¦
Query string parameters:
flat_settingslocalmaster_timeout
See the get_template docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html> for more information. π
π§ exists_template()
$result = $e->indices->exists_template(
name => 'template' # required
);
exists_template() is used to check whether the named template exists. Vibe check on a template, basically. π
Query string parameters:
localmaster_timeout
See the get_template docs <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
);
delete_template() is used to delete a named template. Bye babe, you're archived. π
Query string parameters:
master_timeouttimeoutversionversion_type
See the delete_template docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html> for more information. π
π§βοΈ WARMER METHODS π§βοΈ
ok so warmers are these lil pre-heating gizmos β they warm up brand new segments in your index before your users' searches ever touch them. self-care for your shards, honestly. π
β¨ put_warmer() β¨
$response = $e->indices->put_warmer(
index => 'index' | \@indices, # optional
type => 'type' | \@types, # optional
name => 'warmer', # required
body => { warmer defn } # required
);
put_warmer() makes a new named warmer or updates one that already exists. like, it's giving "warming up the crowd before the main character (your search) walks on stage." π₯
for instance:
$response = $e->indices->put_warmer(
index => 'my_index',
name => 'date_field_warmer',
body => {
sort => 'date'
}
);
query string parameters bestie:
allow_no_indicesexpand_wildcardsignore_unavailablemaster_timeout
see the put_warmer docs over at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html if you wanna go deeper π«Ά
β¨ get_warmer() β¨
$response = $e->indices->get_warmer(
index => 'index' | \@indices, # optional
type => 'type' | \@types, # optional
name => 'warmer' | \@warmers, # optional
);
get_warmer() pulls your warmers back out by name. casual lil fetch, no drama. π
query string parameters:
allow_no_indicesexpand_wildcardsignore_unavailablelocal
see the get_warmer docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html πΈ
β¨ delete_warmer() β¨
$response = $e->indices->get_warmer(
index => 'index' | \@indices, # required
name => 'warmer' | \@warmers, # required
);
delete_warmer() does exactly what it says on the tin β deletes warmers by name. bye bestie ππ
query string parameters:
master_timeout
see the delete_warmer docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html π¦
π STATS METHODS π
β¨ stats() β¨
$result = $e->indices->stats(
index => 'index' | \@indices # optional
metric => 'metric' | \@metrics # optional
);
stats() hands you the statistical tea β about one index, several indices, or literally all of them. by default you get every metric, but if you're feeling selective you can narrow it down with metric.
the allowed metrics are:
_all,completiondocs,fielddata,filter_cache,flush,get,id_cache,indexing,merge,percolate,query_cache,refresh,search,segments,store,warmer
query string parameters:
completion_fieldsfielddata_fieldsfieldsgroupshumanleveltypes
see the stats docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html β
β¨ recovery() β¨
$result = $e->indices->recovery(
index => 'index' | \@indices # optional
);
gives you the inside scoop on shard recoveries that are currently happening. not me peeking at shards mid-heal π©Ή
query string parameters:
active_onlydetailedhuman
see the recovery docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-recovery.html π
β¨ segments() β¨
$result = $e->indices->segments(
index => 'index' | \@indices # optional
);
segments() spills all the info about the segments chillin' inside an index. iykyk π
query string parameters:
allow_no_indicesexpand_wildcardshumanignore_unavailable
see the segments docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-segments.html π
π QUERY AND ANALYSIS METHODS π
β¨ analyze() β¨
$result = $e->indices->analyze(
index => 'index' # optional,
body => 'text to analyze'
);
analyze() takes whatever text is in body and runs it through your specified analyzer, tokenizer, or token filter β and those can be global, or tied to a specific index or field β then it hands you back the tokens. literally the most useful thing ever for debugging analyzer configs, no cap πβ¨
query string parameters:
analyzerchar_filtersfieldfiltersformatprefer_localrewritetexttokenizer
see the analyze docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html π
β¨ validate_query() β¨
$result = $e->indices->validate_query(
index => 'index' | \@indices, # optional
type => 'type' | \@types, # optional
body => { query }
);
validate_query() takes a query in the body and is like "hmm bestie, is this even valid?" β
it's at its most iconic when explain is set to true, because then it also throws an execution plan into the output.
query string parameters:
allow_no_indicesanalyze_wildcardanalyzerdefault_operatordfexpand_wildcardsexplainignore_unavailablelenientlowercase_expanded_termsq
see the validate_query docs at http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-validate.html π§
π AUTHOR π
Enrico Zimuel <enrico.zimuel@elastic.co>
π COPYRIGHT AND LICENSE π
this software is Copyright (c) 2020 by Elasticsearch BV.
it's free software, licensed under:
The Apache License, Version 2.0, January 2004
aaaand that's a wrap on the whole page, bestie!! π this was Search...Indices(3pm) from perl v5.36.0, dated 2022-08-28 β go forth and index slay π
β¨π«Ά
π¦ where this page comes from
- ubuntu noble: libsearch-elasticsearch-client-1-0-perl 6.81-2 Β· Apache-2.0
- ubuntu resolute: libsearch-elasticsearch-client-1-0-perl 6.81-2 Β· Apache-2.0
- ubuntu stonking: libsearch-elasticsearch-client-1-0-perl 6.81-2 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms