Skip to main content

elasticsearch-store / index-manager / IndexManager

Class: IndexManager

Defined in: index-manager.ts:21

Manage Elasticsearch Indices

Constructors​

Constructor​

new IndexManager(client, enableIndexMutations?): IndexManager

Defined in: index-manager.ts:27

Parameters​

ParameterTypeDefault value
clientClientundefined
enableIndexMutationsbooleanisTest

Returns​

IndexManager

Properties​

PropertyModifierTypeDefined in
clientreadonlyClientindex-manager.ts:22
clientMetadatareadonlyClientMetadataindex-manager.ts:23
enableIndexMutationspublicbooleanindex-manager.ts:25

Methods​

exists()​

exists(index): Promise<boolean>

Defined in: index-manager.ts:49

Verify the index exists

Parameters​

ParameterType
indexstring

Returns​

Promise<boolean>


formatIndexName()​

formatIndexName<T>(config, useWildcard?): string

Defined in: index-manager.ts:60

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


formatTemplateName()​

formatTemplateName<T>(config): string

Defined in: index-manager.ts:88

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


getMapping()​

getMapping(index): Promise<IndicesGetMappingResponse>

Defined in: index-manager.ts:296

Parameters​

ParameterType
indexstring

Returns​

Promise<IndicesGetMappingResponse>


getTemplate()​

getTemplate(name, flat_settings): Promise<IndicesGetTemplateResponse>

Defined in: index-manager.ts:386

Parameters​

ParameterType
namestring
flat_settingsboolean

Returns​

Promise<IndicesGetTemplateResponse>


indexSetup()​

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

Defined in: index-manager.ts:105

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


isIndexActive()​

isIndexActive(index): Promise<boolean>

Defined in: index-manager.ts:201

Parameters​

ParameterType
indexstring

Returns​

Promise<boolean>


migrateIndex()​

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

Defined in: index-manager.ts:221

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


putMapping()​

putMapping(index, properties): Promise<IndicesPutMappingResponse>

Defined in: index-manager.ts:302

Parameters​

ParameterType
indexstring
propertiesRecord<string, any>

Returns​

Promise<IndicesPutMappingResponse>


updateMapping()​

updateMapping(index, mapping, logger): Promise<boolean>

Defined in: index-manager.ts:322

Safely update a mapping

WARNING: This only updates the mapping if it exists

Parameters​

ParameterType
indexstring
mappingRecord<string, any>
loggerLogger

Returns​

Promise<boolean>

a boolean that indicates whether the mapping was updated


upsertTemplate()​

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

Defined in: index-manager.ts:402

Safely create or update a template -

NOTE: if version is same it will NOT update template, pass overrideCurrentVersion to allow

Parameters​

ParameterTypeDefault value
templateESMappingundefined
logger?Loggerundefined
overrideCurrentVersion?booleanfalse

Returns​

Promise<void>


waitForIndexAvailability()​

protected waitForIndexAvailability(index): Promise<void>

Defined in: index-manager.ts:433

Parameters​

ParameterType
indexstring

Returns​

Promise<void>