Add ability to force index settings update

This commit is contained in:
Chocobozzz 2024-01-15 10:24:55 +01:00
parent 535b2b6594
commit c7edcd1839
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 8 additions and 3 deletions

View File

@ -17,6 +17,10 @@ meilisearch:
channels: 'peertube-index-channels' channels: 'peertube-index-channels'
playlists: 'peertube-index-playlists' 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: log:
level: 'debug' # debug/info/warning/error level: 'debug' # debug/info/warning/error

View File

@ -19,7 +19,8 @@ const CONFIG = {
VIDEOS: config.get<string>('meilisearch.indexes.videos'), VIDEOS: config.get<string>('meilisearch.indexes.videos'),
CHANNELS: config.get<string>('meilisearch.indexes.channels'), CHANNELS: config.get<string>('meilisearch.indexes.channels'),
PLAYLISTS: config.get<string>('meilisearch.indexes.playlists') PLAYLISTS: config.get<string>('meilisearch.indexes.playlists')
} },
FORCE_SETTINGS_UPDATE_AT_STARTUP: config.get<boolean>('meilisearch.force_settings_update_at_startup')
}, },
LOG: { LOG: {
LEVEL: config.get<string>('log.level') LEVEL: config.get<string>('log.level')

View File

@ -48,12 +48,12 @@ export abstract class AbstractIndexer <T extends IndexableDoc, DB> {
async initIndex () { async initIndex () {
const { results } = await client.getIndexes() 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') logger.info(this.indexName + ' already exists, skipping configuration')
return 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).updateSearchableAttributes(this.searchableAttributes)
await client.index(this.indexName).updateFilterableAttributes(this.filterableAttributes) await client.index(this.indexName).updateFilterableAttributes(this.filterableAttributes)