Skip to main content

elasticsearch-store / index-manager / IndexManager

Class: IndexManager

Manage Elasticsearch Indices

Constructors

new IndexManager()

new IndexManager(client, enableIndexMutations): IndexManager

Parameters

ParameterTypeDefault value
clientClientundefined
enableIndexMutationsbooleanisTest

Returns

IndexManager

Source

elasticsearch-store/src/index-manager.ts:24

Properties

client

readonly client: Client

Source

elasticsearch-store/src/index-manager.ts:19


clientMetadata

readonly clientMetadata: ClientMetadata

Source

elasticsearch-store/src/index-manager.ts:20


enableIndexMutations

enableIndexMutations: boolean

Source

elasticsearch-store/src/index-manager.ts:22

Methods

exists()

exists(index): Promise<boolean>

Verify the index exists

Parameters

ParameterType
indexstring

Returns

Promise<boolean>

Source

elasticsearch-store/src/index-manager.ts:46


formatIndexName()

formatIndexName<T>(config, useWildcard): string

Format the current index name.

Type parameters

Type parameter
T extends Record<string, any>

Parameters

ParameterTypeDefault valueDescription
configIndexConfig<T>undefined-
useWildcardbooleantrueif true a wildcard is added to the end of the end the index name

Returns

string

Source

elasticsearch-store/src/index-manager.ts:57


formatTemplateName()

formatTemplateName<T>(config): string

Format the template name, similar to formatIndexName except it excludes template wildcards and the time series parts of the index name.

Type parameters

Type parameter
T extends Record<string, any>

Parameters

ParameterType
configIndexConfig<T>

Returns

string

Source

elasticsearch-store/src/index-manager.ts:85


getMapping()

getMapping(index): Promise<IndicesGetMappingResponse>

Parameters

ParameterType
indexstring

Returns

Promise<IndicesGetMappingResponse>

Source

elasticsearch-store/src/index-manager.ts:290


getTemplate()

getTemplate(name, flat_settings): Promise<IndicesGetTemplateResponse>

Parameters

ParameterType
namestring
flat_settingsboolean

Returns

Promise<IndicesGetTemplateResponse>

Source

elasticsearch-store/src/index-manager.ts:381


indexSetup()

indexSetup<T>(config): Promise<boolean>

Safely setup a versioned Index, its template and any other required resources

Type parameters

Type parameter
T extends Record<string, any>

Parameters

ParameterType
configIndexConfig<T>

Returns

Promise<boolean>

a boolean that indicates whether the index was created or not

Source

elasticsearch-store/src/index-manager.ts:102


isIndexActive()

isIndexActive(index): Promise<boolean>

Parameters

ParameterType
indexstring

Returns

Promise<boolean>

Source

elasticsearch-store/src/index-manager.ts:195


migrateIndex()

migrateIndex<T>(options): Promise<boolean | ReindexResponse>

Perform an Index Migration

IMPORTANT This is a potentially dangerous operation and should only when the cluster is properly shutdown.

Type parameters

Type parameter
T extends Record<string, any>

Parameters

ParameterType
optionsMigrateIndexOptions<T>

Returns

Promise<boolean | ReindexResponse>

Todo

add support for timeseries and templated indexes

Todo

add support for complicated re-indexing behaviors

Source

elasticsearch-store/src/index-manager.ts:215


putMapping()

putMapping(index, type, properties): Promise<IndicesPutMappingResponse>

Parameters

ParameterType
indexstring
typestring
propertiesRecord<string, any>

Returns

Promise<IndicesPutMappingResponse>

Source

elasticsearch-store/src/index-manager.ts:296


updateMapping()

updateMapping(index, type, mapping, logger): Promise<void>

Safely update a mapping

WARNING: This only updates the mapping if it exists

Parameters

ParameterType
indexstring
typestring
mappingRecord<string, any>
loggerLogger

Returns

Promise<void>

Source

elasticsearch-store/src/index-manager.ts:315


upsertTemplate()

upsertTemplate(template, logger?): Promise<void>

Safely create or update a template

Parameters

ParameterType
templateESMapping
logger?Logger

Returns

Promise<void>

Source

elasticsearch-store/src/index-manager.ts:395


waitForIndexAvailability()

protected waitForIndexAvailability(index): Promise<void>

Parameters

ParameterType
indexstring

Returns

Promise<void>

Source

elasticsearch-store/src/index-manager.ts:426