Table of Contents

Class IndexAliasManager

Namespace
Excalibur.Data.ElasticSearch.IndexManagement
Assembly
Excalibur.Data.ElasticSearch.dll

Provides functionality for managing Elasticsearch index aliases.

public sealed class IndexAliasManager : IIndexAliasManager
Inheritance
IndexAliasManager
Implements
Inherited Members

Remarks

Initializes a new instance of the IndexAliasManager class.

Constructors

IndexAliasManager(ElasticsearchClient, ILogger<IndexAliasManager>)

Provides functionality for managing Elasticsearch index aliases.

public IndexAliasManager(ElasticsearchClient client, ILogger<IndexAliasManager> logger)

Parameters

client ElasticsearchClient

The Elasticsearch client instance.

logger ILogger<IndexAliasManager>

The logger instance.

Remarks

Initializes a new instance of the IndexAliasManager class.

Exceptions

ArgumentNullException

Thrown if any parameter is null.

Methods

AliasExistsAsync(string, CancellationToken)

Checks if an alias exists in Elasticsearch.

public Task<bool> AliasExistsAsync(string aliasName, CancellationToken cancellationToken)

Parameters

aliasName string

The name of the alias to check.

cancellationToken CancellationToken

The cancellation token to cancel the operation if required.

Returns

Task<bool>

A Task<TResult> indicating whether the alias exists.

Exceptions

ArgumentNullException

Thrown if any parameter is null.

CreateAliasAsync(string, IEnumerable<string>, JsonElement?, CancellationToken)

Creates or updates an alias for the specified indices.

public Task<bool> CreateAliasAsync(string aliasName, IEnumerable<string> indexNames, JsonElement? aliasConfigurationJson, CancellationToken cancellationToken)

Parameters

aliasName string

The name of the alias.

indexNames IEnumerable<string>

The names of the indices to include in the alias.

aliasConfigurationJson JsonElement?

Optional alias configuration settings as opaque JSON.

cancellationToken CancellationToken

The cancellation token to cancel the operation if required.

Returns

Task<bool>

A Task<TResult> indicating whether the operation was successful.

Exceptions

ArgumentNullException

Thrown if any parameter is null.

DeleteAliasAsync(string, IEnumerable<string>?, CancellationToken)

Deletes an alias from Elasticsearch.

public Task<bool> DeleteAliasAsync(string aliasName, IEnumerable<string>? indexNames, CancellationToken cancellationToken)

Parameters

aliasName string

The name of the alias to delete.

indexNames IEnumerable<string>

The names of the indices to remove the alias from. If null, removes from all indices.

cancellationToken CancellationToken

The cancellation token to cancel the operation if required.

Returns

Task<bool>

A Task<TResult> indicating whether the operation was successful.

Exceptions

ArgumentNullException

Thrown if any parameter is null.

GetAliasesAsync(string?, CancellationToken)

Gets all aliases that match the specified pattern.

public Task<IEnumerable<AliasDefinition>> GetAliasesAsync(string? aliasPattern, CancellationToken cancellationToken)

Parameters

aliasPattern string

The pattern to match alias names against. If null, returns all aliases.

cancellationToken CancellationToken

The cancellation token to cancel the operation if required.

Returns

Task<IEnumerable<AliasDefinition>>

A Task<TResult> containing the matching aliases.

Exceptions

ArgumentNullException

Thrown if any parameter is null.

UpdateAliasesAsync(IEnumerable<AliasOperation>, CancellationToken)

Performs atomic alias operations to switch indices behind an alias.

public Task<bool> UpdateAliasesAsync(IEnumerable<AliasOperation> operations, CancellationToken cancellationToken)

Parameters

operations IEnumerable<AliasOperation>

The alias operations to perform atomically.

cancellationToken CancellationToken

The cancellation token to cancel the operation if required.

Returns

Task<bool>

A Task<TResult> indicating whether the operation was successful.

Exceptions

ArgumentNullException

Thrown if any parameter is null.