diff --git a/plugins/search-backend-module-elasticsearch/config.d.ts b/plugins/search-backend-module-elasticsearch/config.d.ts index df9852c922..e0717e33cc 100644 --- a/plugins/search-backend-module-elasticsearch/config.d.ts +++ b/plugins/search-backend-module-elasticsearch/config.d.ts @@ -21,6 +21,10 @@ export interface Config { * Options for ElasticSearch */ elasticsearch?: { + /** + * Prefix to be used for all index creation. Value will be put in front of the index as is. + */ + indexPrefix?: string; /** * Batch size for elastic search indexing tasks. Defaults to 1000. */ diff --git a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngineIndexer.ts b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngineIndexer.ts index 3af195bd55..4faa2f86dd 100644 --- a/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngineIndexer.ts +++ b/plugins/search-backend-module-elasticsearch/src/engines/ElasticSearchSearchEngineIndexer.ts @@ -140,7 +140,7 @@ export class ElasticSearchSearchEngineIndexer extends BatchSearchEngineIndexer { // does not occur, and clean up the empty index we just created. if (this.processed === 0) { this.logger.warn( - `Index for ${this.type} was not ${ + `Index for ${this.indexName} was not ${ this.removableIndices.length ? 'replaced' : 'created' }: indexer received 0 documents`, ); @@ -158,7 +158,7 @@ export class ElasticSearchSearchEngineIndexer extends BatchSearchEngineIndexer { // stale indices can be referenced for deletion in case initial attempt // fails. Allow errors to bubble up so that we can clean up the created index. this.logger.info( - `Indexing completed for index ${this.type} in ${duration( + `Indexing completed for index ${this.indexName} in ${duration( this.startTimestamp, )}`, result, diff --git a/plugins/search-backend-module-elasticsearch/src/module.ts b/plugins/search-backend-module-elasticsearch/src/module.ts index 827c8d48b8..3d45d19d0c 100644 --- a/plugins/search-backend-module-elasticsearch/src/module.ts +++ b/plugins/search-backend-module-elasticsearch/src/module.ts @@ -76,12 +76,20 @@ export default createBackendModule({ ); return; } - + const indexPrefix = config.getOptionalString( + 'search.elasticsearch.indexPrefix', + ); + if (indexPrefix) { + logger.info( + `Preceeding all indices with index prefix: ${indexPrefix}`, + ); + } searchEngineRegistry.setSearchEngine( await ElasticSearchSearchEngine.fromConfig({ logger, config, translator, + indexPrefix, }), ); },