diff --git a/opencti-platform/opencti-graphql/src/database/engine.js b/opencti-platform/opencti-graphql/src/database/engine.js index c87655c573e2..5e67c0df6ae4 100644 --- a/opencti-platform/opencti-graphql/src/database/engine.js +++ b/opencti-platform/opencti-graphql/src/database/engine.js @@ -179,7 +179,9 @@ const OPENSEARCH_ENGINE = 'opensearch'; export const ES_MAX_CONCURRENCY = conf.get('elasticsearch:max_concurrency'); export const ES_DEFAULT_WILDCARD_PREFIX = booleanConf('elasticsearch:search_wildcard_prefix', false); export const ES_DEFAULT_FUZZY = booleanConf('elasticsearch:search_fuzzy', false); -export const ES_INIT_RETRO_MAPPING_MIGRATION = booleanConf('elasticsearch:internal_init_retro_compatible_mapping_migration', false); +export const ES_INIT_MAPPING_MIGRATION = conf.get('elasticsearch:internal_init_mapping_migration') || 'off'; // off / old / standard +export const ES_IS_OLD_MAPPING = ES_INIT_MAPPING_MIGRATION === 'old'; +export const ES_IS_INIT_MIGRATION = ES_INIT_MAPPING_MIGRATION === 'standard' || ES_IS_OLD_MAPPING; export const ES_MINIMUM_FIXED_PAGINATION = 20; // When really low pagination is better by default export const ES_DEFAULT_PAGINATION = conf.get('elasticsearch:default_pagination_result') || 500; export const ES_MAX_PAGINATION = conf.get('elasticsearch:max_pagination_result') || 5000; @@ -992,7 +994,7 @@ const updateIndexTemplate = async (name, mapping_properties) => { index_patterns: [index_pattern], template: { settings: computeIndexSettings(name), - mappings: ES_INIT_RETRO_MAPPING_MIGRATION ? { + mappings: ES_IS_OLD_MAPPING ? { properties: getRetroCompatibleMappings() } : { // Global option to prevent elastic to try any magic diff --git a/opencti-platform/opencti-graphql/src/initialization.js b/opencti-platform/opencti-graphql/src/initialization.js index 895a6b7d87f1..bc8ed6f14180 100644 --- a/opencti-platform/opencti-graphql/src/initialization.js +++ b/opencti-platform/opencti-graphql/src/initialization.js @@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid'; import semver from 'semver'; import { ENABLED_FEATURE_FLAGS, logApp, PLATFORM_VERSION } from './config/conf'; -import { elUpdateIndicesMappings, ES_INIT_RETRO_MAPPING_MIGRATION, initializeSchema, searchEngineInit } from './database/engine'; +import { elUpdateIndicesMappings, ES_INIT_MAPPING_MIGRATION, ES_IS_INIT_MIGRATION, initializeSchema, searchEngineInit } from './database/engine'; import { initializeAdminUser } from './config/providers'; import { initializeBucket, storageInit } from './database/file-storage'; import { enforceQueuesConsistency, initializeInternalQueues, rabbitMQIsAlive } from './database/rabbitmq'; @@ -98,9 +98,9 @@ const platformInit = async (withMarkings = true) => { await initializeInternalQueues(); await initializeBucket(); await initializeSchema(); - if (ES_INIT_RETRO_MAPPING_MIGRATION) { - logApp.warn('Templates and indices created with retro compatible mapping protection. ' - + 'This is only used to help indices reindex and migration. Please reindex, restart and then ' + if (ES_IS_INIT_MIGRATION) { + logApp.warn(`Templates and indices created with ${ES_INIT_MAPPING_MIGRATION} compatible mapping protection. ` + + 'This is only used to help indices reindex and migration. For retro option, please reindex, restart and then ' + 'trigger a rollover to secure the new indices'); process.exit(1); } @@ -110,9 +110,9 @@ const platformInit = async (withMarkings = true) => { await initDefaultNotifiers(context); } else { logApp.info('[INIT] Existing platform detected, initialization...'); - if (ES_INIT_RETRO_MAPPING_MIGRATION) { + if (ES_IS_INIT_MIGRATION) { // noinspection ExceptionCaughtLocallyJS - throw ConfigurationError('Internal option internal_init_retro_compatible_mapping_migration is only available for new platform init'); + throw ConfigurationError('Internal option internal_init_mapping_migration is only available for new platform init'); } await refreshMappingsAndIndices(); await initializeInternalQueues();