Search...Indices(3pm)

πŸ“¦
version 6.81 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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_timeout
  • timeout

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_indices
  • expand_wildcards
  • ignore_unavailable
  • local

🌟 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_indices
  • expand_wildcards
  • ignore_unavailable
  • local

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_indices
  • expand_wildcards
  • ignore_unavailable
  • master_timeout
  • timeout

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_indices
  • expand_wildcards
  • ignore_unavailable
  • master_timeout
  • timeout

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_indices
  • expand_wildcards
  • ignore_unavailable
  • master_timeout
  • timeout

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_indices
  • expand_wildcards
  • fielddata
  • fields
  • filter
  • filter_cache
  • filter_keys
  • id
  • id_cache
  • ignore_unavailable
  • query_cache
  • recycler

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_indices
  • expand_wildcards
  • force
  • ignore_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_indices
  • expand_wildcards
  • force
  • full
  • ignore_unavailable
  • wait_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_indices
  • expand_wildcards
  • flush
  • ignore_unavailable
  • max_num_segments
  • only_expunge_deletes
  • wait_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_indices
  • 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. The actual glow-up. πŸ‘‘

Query string parameters:

  • allow_no_indices
  • expand_wildcards
  • 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 🌸

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_indices
  • expand_wildcards
  • ignore_unavailable
  • ignore_conflicts
  • master_timeout
  • timeout

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_indices
  • expand_wildcards
  • ignore_unavailable
  • local

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_indices
  • expand_wildcards
  • ignore_unavailable
  • include_defaults
  • local

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_indices
  • expand_wildcards
  • ignore_unavailable
  • local

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_timeout
  • timeout

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:

  • local
  • timeout

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_timeout
  • timeout

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_indices
  • expand_wildcards
  • ignore_unavailable
  • local

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_indices
  • expand_wildcards
  • ignore_unavailable
  • local

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_timeout
  • timeout

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_indices
  • expand_wildcards
  • flat_settings
  • ignore_unavailable
  • master_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_indices
  • expand_wildcards
  • flat_settings
  • ignore_unavailable
  • local

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:

  • create
  • flat_settings
  • master_timeout
  • op_type
  • order
  • timeout
  • version
  • version_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_settings
  • 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'                 # required
);

exists_template() is used to check whether the named template exists. Vibe check on a template, basically. πŸ’…

Query string parameters:

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

delete_template() is used to delete a named template. Bye babe, you're archived. 😭

Query string parameters:

  • 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. πŸ“–

πŸ§–β™€οΈ 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_indices
  • expand_wildcards
  • ignore_unavailable
  • master_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_indices
  • expand_wildcards
  • ignore_unavailable
  • local

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,
  • completion
  • docs,
  • fielddata,
  • filter_cache,
  • flush,
  • get,
  • id_cache,
  • indexing,
  • merge,
  • percolate,
  • query_cache,
  • refresh,
  • search,
  • segments,
  • store,
  • warmer

query string parameters:

  • completion_fields
  • fielddata_fields
  • fields
  • groups
  • human
  • level
  • types

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_only
  • detailed
  • human

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_indices
  • expand_wildcards
  • human
  • ignore_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:

  • analyzer
  • char_filters
  • field
  • filters
  • format
  • prefer_local
  • rewrite
  • text
  • tokenizer

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_indices
  • analyze_wildcard
  • analyzer
  • default_operator
  • df
  • expand_wildcards
  • explain
  • ignore_unavailable
  • lenient
  • lowercase_expanded_terms
  • q

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>


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