The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

OpenSearch::Index - OpenSearch Index API Endpoints

SYNOPSIS

use OpenSearch;

my $os = OpenSearch->new(...);
my $api = $os->index;

$api->create( index => 'my_index' );
$api->delete( index => 'my_index' );
#...

DESCRIPTION

This module provides an interface to the OpenSearch Index API endpoints. If i read the documentation correctly, all endpoints are supported. For a list of avaialable parameters see: https://opensearch.org/docs/latest/api-reference/index-apis/

RETURN VALUES

When the async attribute is set to true:

my $os = OpenSearch->new(
  ...
  async => 1
);

all methods return a Mojo::Promise object that will resolve to a OpenSearch::Response object. Otherwise, it will directly return a OpenSearch::Response object.

METHODS

  • create

    $api->create( index => 'my_index' );
    
    # With addtional parameters
    $api->create( 
      index => 'my_index',
      timeout => '1m'
    );
  • delete

    $api->delete( index => 'my_index' );
    
    # With addtional parameters
    $api->delete( 
      index => 'my_index',
      ignore_unavailable => 1
    );

    Deletes an index.

  • set_aliases

    $api->set_aliases( 
      index => 'my_index', 
      actions => [ 
        { 
          add => { index => 'my_index', alias => 'my_alias' } 
        },
        { 
          remove => { index => 'my_index_old', alias => 'my_alias_old' } 
        }
      ]);
  • get_aliases

    $api->get_aliases( index => 'my_index' );

    Get aliases for an index.

  • clear_cache

    $api->clear_cache( index => 'my_index' );

    Clears the cache for an index.

  • clone

    $api->clone( 
      index => 'my_index', 
      target => 'my_index_clone',
      settings => { 
        index => {number_of_shards => 1} 
      },
      aliases => {
        my_alias => {}
      }
    );

    Clones an index.

  • close

    $api->close( index => 'my_index' );

    Closes an index.

  • set_mappings

    $api->set_mappings( 
      index => 'my_index', 
      properties => {
        my_field => { type => 'text' }
      },
      dynamic => 'strict'
    );

    Sets mappings for an index.

  • get_mappings

    $api->get_mappings( 
      index => 'my_index' 
      field => 'my_field'
    );

    Get mappings for an index.

  • get_dangling

    $api->get_dangling;

    Get dangling indices.

  • import_dangling

    $api->import_dangling( 
      index_uuid => 'my_index_uuid' 
    );

    Import a dangling index.

  • delete_dangling

    $api->delete_dangling( 
      index_uuid => 'my_index_uuid' 
    );

    Delete a dangling index.

  • get

    $api->get( index => 'my_index' );

    Get an index.

  • exists

    $api->exists( index => 'my_index' );

    Check if an index exists.

  • force_merge

    $api->force_merge( index => 'my_index' );

    Force merge an index.

  • open

    $api->open( index => 'my_index' );

    Open an index.

  • refresh

    $api->refresh( index => 'my_index' );

    Refresh an index.

  • shrink

    $api->shrink( 
      index => 'my_index', 
      target => 'my_index_shrink',
      settings => { 
        index => {number_of_shards => 1} 
      }
    );

    Shrink an index.

  • split

    $api->split( 
      index => 'my_index', 
      target => 'my_index_split',
      settings => { 
        index => {number_of_shards => 1} 
      },
      aliases => {
        my_alias => {}
      }
    );

    Split an index.

  • stats

    $api->stats( index => 'my_index' );
    $api->stats( index => 'my_index', metrics => 'docs' );

    Get stats for an index.

  • get_settings

    $api->get_settings( 
      index => 'my_index' 
      flat_settings => 1
    );

    Get settings for an index.

  • update_settings

    $api->update_settings( 
      index => 'my_index', 
      settings => { 
        index => {number_of_shards => 1},
        "index.number_of_replicas" => 5
      }
    );

    Update settings for an index.

AUTHOR

OpenSearch::Index Perl Module was written by Sebastian Grenz, <git at fail.ninja>