enable configuration of indexPrefix

Signed-off-by: Kiss Miklos <miklos@roadie.io>
This commit is contained in:
Kiss Miklos
2025-01-31 15:36:19 +01:00
parent 72f9a9d1ff
commit 95ad2b0064
3 changed files with 15 additions and 3 deletions
@@ -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.
*/
@@ -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,
@@ -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,
}),
);
},