Search...Indices(3pm)

πŸ“¦ version 7.715, in ubuntu jammy

✨ NAME ✨

Search::Elasticsearch::Client::7_0::Direct::Indices β€” bestie, it's a client for running index-level requests. that's the whole vibe, no cap.

🌸 VERSION 🌸

version 7.715

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so this module is your group chat for index-level requests β€” creating and deleting indices, managing type mappings, index settings, index templates and aliases. all of it, all the index admin energy. πŸ’…

It does Search::Elasticsearch::Role::Client::Direct. (iykyk)


πŸ‘‘ INDEX METHODS πŸ‘‘

πŸ’– create()

$result = $e->indices->create(
    index => 'my_index'             # required

    body  => {                      # optional
        index settings
        mappings
        aliases
    }
);

The create() method makes you a whole new index. and if you're feeling extra, you can pile on index settings, type mappings, and aliases at the exact same time. iconic behavior honestly. ✨

Query string parameters:

  • error_trace
  • human
  • include_type_name
  • master_timeout
  • timeout
  • update_all_types
  • wait_for_active_shards

See the create index docs 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
);

Hands you back the aliases, settings, and mappings for whichever indices you asked about. the full receipts. 🧾

See the get index docs http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html.

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • flat_settings
  • human
  • ignore_unavailable
  • include_defaults
  • include_type_name
  • local
  • master_timeout

πŸŽ€ exists()

$bool = $e->indices->exists(
    index => 'index' | \@indices    # required
);

The exists() method gives you back 1 or the empty string, telling you whether that index (or those indices) exist or not. simple yes/no energy. 🫢

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • flat_settings
  • human
  • ignore_unavailable
  • include_defaults
  • local

See the index exists docs 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 indices you point at. poof. gone. be careful bestie, this one does not un-happen. 😭

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable
  • master_timeout
  • timeout

See the delete index docs 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's giving low resource usage, but the best part is they can be reopened later. it's not a delete, it's a nap. 😴

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable
  • master_timeout
  • timeout

See the close index docs 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 back up. nap time is over, we're awake and thriving. 🌈

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable
  • master_timeout
  • timeout
  • wait_for_active_shards

See the open index docs 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
);

Rolls an index pointed to by alias over to a new index name, but only if it meets the rollover conditions (eg max age, max docs). it's the "new year new me" of indices. ✨

Query string parameters:

  • dry_run
  • error_trace
  • human
  • include_type_name
  • master_timeout
  • timeout
  • wait_for_active_shards

See the rollover index docs 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 down to a factor of the original shards). little tiny shards, so cute. πŸ₯Ί

Query string parameters:

  • copy_settings
  • error_trace
  • filter_path
  • human
  • master_timeout
  • timeout
  • wait_for_active_shards

See the shrink index docs 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. one becomes many, the reverse of shrinking, we love a glow-up arc. πŸ¦‹

Query string parameters:

  • copy_settings
  • error_trace
  • filter_path
  • human
  • master_timeout
  • timeout
  • wait_for_active_shards

See the split index docs 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 freezes an index, which puts it into a state that has almost no overhead on the cluster. it's giving "quiet luxury". 🀫

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • filter_path
  • human
  • ignore_unavailable
  • master_timeout
  • timeout
  • wait_for_active_shards

See the freeze index docs 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 brings a frozen index back to its normal state. the thaw. the comeback. πŸ”₯

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • filter_path
  • human
  • ignore_unavailable
  • master_timeout
  • timeout
  • wait_for_active_shards

See the unfreeze index docs 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 clears the in-memory filter, fielddata, or id cache for the specified indices. spring cleaning but make it elasticsearch. 🧼

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • fielddata
  • fields
  • human
  • ignore_unavailable
  • query
  • request

See the clear_cache docs 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 of them if you don't specify), letting recent changes become visible to search. and ngl, this whole thing normally just happens automatically once every second by default. you're just speeding up the timeline. ⏩

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable

See the refresh index docs 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 clears out the transaction log. again β€” this normally happens automatically, you're just doing it on purpose. πŸ’…

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • force
  • human
  • ignore_unavailable
  • wait_if_ongoing

See the flush index docs 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. πŸƒβ€β™€οΈπŸ’¨

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 http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-synced-flush.html for more information.

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • 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.

bestie 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 yolo this one. 😭

okay so the query string parameters for that forcemerge call are:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • flush
  • human
  • ignore_unavailable
  • max_num_segments
  • only_expunge_deletes

and if you wanna go deeper, the forcemerge docs live at <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-forcemerge.html> πŸ’–


get_upgrade()</p> β€” the "who needs a glow-up" check ✨

$response = $e->indices->get_upgrade(
    index => 'index' | \@indices    # optional
);

bestie, this one tells you which indices are overdue for an upgrade β€” like, which ones need the glow-up that upgrade() actually performs. it's the vibe check before the makeover. πŸ‘‘

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable

more deets in the upgrade docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html> πŸ¦‹


upgrade() β€” actual glow-up time πŸ’…

$response = $e->indices->upgrade(
    index => 'index' | \@indices    # optional
);

this method upgrades all the segments in the indices you point at, bringing them to the latest format. literally a whole new you, but for segments. ✨

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable
  • only_ancient_segments
  • wait_for_completion

the upgrade docs are right here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-upgrade.html> 🌸


MAPPING METHODS 🌈

put_mapping()

$response = $e->indices->put_mapping(
    index => 'index' | \@indices    # optional,
    type  => 'type',                # optional

    body  => { mapping }            # required
)

so put_mapping() creates or updates a type mapping on an index that already exists. important though β€” mapping updates can add new fields, but they can NOT overwrite or change fields that are already there. no takebacks, no editing, it's giving locked-in. πŸ”’

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

put_mapping docs, right this way <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html> πŸ’–


get_mapping()

$result = $e->indices->get_mapping(
    index => 'index' | \@indices    # optional,
    type  => 'type'  | \@types      # optional
);

this one hands you back the type definitions for one, several, or literally all types across one, several, or all indices. the receipts for your mappings, basically. πŸ“‹βœ¨

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable
  • include_type_name
  • local
  • master_timeout

get_mapping docs live here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html> πŸ¦‹


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
);

this one is the hyper-specific version β€” it returns the field definitions for one, several, or all fields, in one, several, or all types and indices. it's giving microscope energy πŸ”¬πŸ’…

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable
  • include_defaults
  • include_type_name
  • local

the get_mapping docs are over here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-field-mapping.html> 🌸


exists_type()

$bool = $e->indices->exists_type(
    index => 'index' | \@indices    # required,
    type  => 'type'  | \@types      # required
);

this method checks whether all the types you named exist in all the indices you named, and it returns 1 or the empty string. like a yes/no but the no is just... nothing. silent treatment fr. πŸ™ˆ

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable
  • local

exists_type docs are right here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-types-exists.html> ✨


ALIAS METHODS πŸŽ€

update_aliases()

$response = $e->indices->update_aliases(
    body => { actions }             # required
);

so this one changes multiple index aliases atomically β€” adding and removing them in one single swoop. no half-finished chaos, it's all-or-nothing, main character efficiency. πŸ’…

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:

  • error_trace
  • human
  • master_timeout
  • timeout

update_aliases docs, come thru <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html> πŸ”₯


put_alias()

$response = $e->indices->put_alias(
    index => 'index' | \@indices,       # required
    name  => 'alias',                   # required

    body  => { alias defn }             # optional
);

creates an index alias. new nickname for your index, obsessed. ✨

for instance:

$response = $e->indices->put_alias(
    index => 'my_index',
    name  => 'twitter',
    body => {
        filter => { term => { user_id => 'twitter' }}
    }
);

Query string parameters:

  • error_trace
  • human
  • master_timeout
  • timeout

put_alias docs right here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html> πŸ¦‹


get_alias()

$result = $e->indices->get_alias(
    index   => 'index' | \@indices,     # optional
    name    => 'alias' | \@aliases      # optional
);

this one returns the alias definitions for the aliases you asked for, in the indices you asked for. the alias lore, served fresh. πŸ“œπŸ’–

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable
  • local

get_alias docs over here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html> 🌸


exists_alias()

$bool = $e->indices->exists_alias(
    index   => 'index' | \@indices,     # optional
    name    => 'alias' | \@aliases      # required
);

returns 1 or the empty string, depending on whether the aliases you named actually exist in the indices you named. do they exist? do they not? the suspense. 😭

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • human
  • ignore_unavailable
  • local

exists_alias docs are here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html> ✨


delete_alias()

$response = $e->indices->delete_alias(
    index   => 'index' | \@indices        # required,
    name    => 'alias' | \@aliases        # required
);

deletes one or more aliases from one or more indices. rip to those nicknames, they served well 🫢

Query string parameters:

  • error_trace
  • human
  • master_timeout
  • timeout

delete_alias docs live here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html> πŸ’…


SETTINGS METHODS ⭐

put_settings()

$response = $e->indices->put_settings(
    index   => 'index' | \@indices      # optional

    body    => { settings }
);

sets the index settings for the indices you specify β€” or for all indices if you don't. 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

put_settings docs right here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-update-settings.html> πŸ”₯


get_settings()

$result = $e->indices->get_settings(
    index   => 'index' | \@indices      # optional
    name    => 'name'  | \@names        # optional
);

retrieves the index settings for the indices you named, or for all of them. the settings receipts, handed to you directly. πŸ§ΎπŸ’–

Query string parameters:

  • allow_no_indices
  • error_trace
  • expand_wildcards
  • flat_settings
  • human
  • ignore_unavailable
  • include_defaults
  • local
  • master_timeout

get_settings docs are over here <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html> 🌸


✨ TEMPLATE METHODS ✨

πŸ’– put_template()

$response = $e->indices->put_template(
    name => 'template'                  # required
    body => { template defn }           # required
);

The put_template() method is your girl for creating or updating index templates β€” brand new one? updated glow-up? either way, slay. πŸŽ€

Query string parameters:

  • "create"
  • "error_trace"
  • "flat_settings"
  • "human"
  • "include_type_name"
  • "master_timeout"
  • "order"
  • "timeout"

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' | \@templates # optional
);

The get_template() method retrieves a named template β€” like, come here bestie, let me see you. πŸ‘‘

Query string parameters:

  • "error_trace"
  • "flat_settings"
  • "human"
  • "include_type_name"
  • "local"
  • "master_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'                 # optional
);

The exists_template() method checks whether the named template exists β€” vibe check, but for templates. πŸ”

Query string parameters:

  • "error_trace"
  • "flat_settings"
  • "human"
  • "local"
  • "master_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
);

The delete_template() method deletes a named template. gone, bye, no notes. πŸ’…

Query string parameters:

  • "error_trace"
  • "human"
  • "master_timeout"
  • "timeout"
  • "version"
  • "version_type"

See the delete_template docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html> for more information. πŸ“


πŸ“Š STATS METHODS πŸ“Š

πŸ”₯ stats()

$result = $e->indices->stats(
    index   => 'index'  | \@indices      # optional
    metric  => 'metric' | \@metrics      # optional
);

The stats() method hands you statistical information about one, more or all indices. By default it's giving everything β€” all the metrics β€” but you can narrow it down by saying which metric you actually want. main character energy, but make it data. πŸ“ˆ

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 <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 peeking behind the curtain while the shards are doing their little healing arc. 🧚

Query string parameters:

  • "active_only",
  • "detailed",
  • "error_trace",
  • "human"

See the recovery docs <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. the receipts, basically. 🧾

Query string parameters:

  • "allow_no_indices",
  • "error_trace",
  • "expand_wildcards",
  • "human",
  • "ignore_unavailable",
  • "verbose"

See the segments docs <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. literally who's holding what. πŸ—ΊοΈ

Query string parameters:

  • "allow_no_indices",
  • "error_trace",
  • "expand_wildcards",
  • "human",
  • "ignore_unavailable",
  • "status"

See the shard_stores docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-shards-stores.html> 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 β€” and those can be global, or tied to a particular index or field β€” then it hands back the tokens. Very useful for debugging analyzer configurations. ngl this one is so good for figuring out why your analyzer is acting up. 😭

Query string parameters:

  • "error_trace",
  • "human"

See the analyze docs <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. It's at its most useful when explain is set to "true" β€” because then it includes an execution plan in the output. like, not just "yeah it's fine" but the whole why. πŸ•΅οΈ

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 <http://www.elastic.co/guide/en/elasticsearch/reference/current/indices-validate.html> for more information. πŸ”₯


πŸ’Œ AUTHOR πŸ’Œ

Enrico Zimuel <enrico.zimuel@elastic.co> β€” icon behavior, fr fr. 🫢


This software is Copyright (c) 2021 by Elasticsearch BV.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004

okay bestie that's the whole page, we made it to the end and honestly? we ate. πŸ’…βœ¨ this was Search...Indices(3pm) from the Perl v5.32.1 era, dated 2021-10-23, courtesy of the User Contributed Perl Documentation crew. go forth and index responsibly, ily πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from