Add ability to force index settings update
This commit is contained in:
parent
535b2b6594
commit
c7edcd1839
|
@ -17,6 +17,10 @@ meilisearch:
|
|||
channels: 'peertube-index-channels'
|
||||
playlists: 'peertube-index-playlists'
|
||||
|
||||
# Avoid updating index settings at startup
|
||||
# Set to true when a new release of the search index updates index settings
|
||||
force_settings_update_at_startup: false
|
||||
|
||||
log:
|
||||
level: 'debug' # debug/info/warning/error
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ const CONFIG = {
|
|||
VIDEOS: config.get<string>('meilisearch.indexes.videos'),
|
||||
CHANNELS: config.get<string>('meilisearch.indexes.channels'),
|
||||
PLAYLISTS: config.get<string>('meilisearch.indexes.playlists')
|
||||
}
|
||||
},
|
||||
FORCE_SETTINGS_UPDATE_AT_STARTUP: config.get<boolean>('meilisearch.force_settings_update_at_startup')
|
||||
},
|
||||
LOG: {
|
||||
LEVEL: config.get<string>('log.level')
|
||||
|
|
|
@ -48,12 +48,12 @@ export abstract class AbstractIndexer <T extends IndexableDoc, DB> {
|
|||
async initIndex () {
|
||||
const { results } = await client.getIndexes()
|
||||
|
||||
if (results.some(r => r.uid === this.indexName)) {
|
||||
if (!CONFIG.MEILISEARCH.FORCE_SETTINGS_UPDATE_AT_STARTUP && results.some(r => r.uid === this.indexName)) {
|
||||
logger.info(this.indexName + ' already exists, skipping configuration')
|
||||
return
|
||||
}
|
||||
|
||||
logger.info('Creating and configuring index ' + this.indexName)
|
||||
logger.info(`Creating/updating "${this.indexName}" index settings`)
|
||||
|
||||
await client.index(this.indexName).updateSearchableAttributes(this.searchableAttributes)
|
||||
await client.index(this.indexName).updateFilterableAttributes(this.filterableAttributes)
|
||||
|
|
Loading…
Reference in New Issue