diff --git a/opencti-platform/opencti-graphql/src/database/engine.js b/opencti-platform/opencti-graphql/src/database/engine.js index 3df3a62feda1..a4eff830b72f 100644 --- a/opencti-platform/opencti-graphql/src/database/engine.js +++ b/opencti-platform/opencti-graphql/src/database/engine.js @@ -4051,7 +4051,7 @@ export const elIndexElements = async (context, user, indexingType, elements) => const body = transformedElements.flatMap((elementDoc) => { const doc = elementDoc; return [ - { index: { _index: doc._index, _id: doc.internal_id, retry_on_conflict: ES_RETRY_ON_CONFLICT } }, + { index: { _index: doc._index, _id: doc._id ?? doc.internal_id, retry_on_conflict: ES_RETRY_ON_CONFLICT } }, R.pipe(R.dissoc('_index'))(doc), ]; }); @@ -4142,7 +4142,7 @@ export const elUpdateRelationConnections = async (elements) => { const source = 'def conn = ctx._source.connections.find(c -> c.internal_id == params.id); ' + 'for (change in params.changes.entrySet()) { conn[change.getKey()] = change.getValue() }'; const bodyUpdate = elements.flatMap((doc) => [ - { update: { _index: doc._index, _id: doc.id, retry_on_conflict: ES_RETRY_ON_CONFLICT } }, + { update: { _index: doc._index, _id: doc._id ?? doc.id, retry_on_conflict: ES_RETRY_ON_CONFLICT } }, { script: { source, params: { id: doc.toReplace, changes: doc.data } } }, ]); const bulkPromise = elBulk({ refresh: true, timeout: BULK_TIMEOUT, body: bodyUpdate }); @@ -4170,7 +4170,7 @@ export const elUpdateEntityConnections = async (elements) => { const bodyUpdate = elements.flatMap((doc) => { const refField = isStixRefRelationship(doc.relationType) && isInferredIndex(doc._index) ? ID_INFERRED : ID_INTERNAL; return [ - { update: { _index: doc._index, _id: doc.id, retry_on_conflict: ES_RETRY_ON_CONFLICT } }, + { update: { _index: doc._index, _id: doc._id ?? doc.id, retry_on_conflict: ES_RETRY_ON_CONFLICT } }, { script: { source, diff --git a/opencti-platform/opencti-graphql/src/migrations/1611671597858-standard_id.js b/opencti-platform/opencti-graphql/src/migrations/1611671597858-standard_id.js index b3d83514d5de..f00afa23c025 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1611671597858-standard_id.js +++ b/opencti-platform/opencti-graphql/src/migrations/1611671597858-standard_id.js @@ -17,7 +17,7 @@ export const up = async (next) => { .map((att) => { const newId = generateStandardId(att.entity_type, att); return [ - { update: { _index: att._index, _id: att.id } }, + { update: { _index: att._index, _id: att._id } }, { doc: { standard_id: newId, x_opencti_stix_ids: [] } }, ]; }) diff --git a/opencti-platform/opencti-graphql/src/migrations/1612381566895-clear_indicates_indexation.js b/opencti-platform/opencti-graphql/src/migrations/1612381566895-clear_indicates_indexation.js index b8e0b4f4a639..c895869b0a70 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1612381566895-clear_indicates_indexation.js +++ b/opencti-platform/opencti-graphql/src/migrations/1612381566895-clear_indicates_indexation.js @@ -18,7 +18,7 @@ export const up = async (next) => { .filter((n) => n.entity_type !== ENTITY_TYPE_INDICATOR) .map((att) => { return [ - { update: { _index: att._index, _id: att.id } }, + { update: { _index: att._index, _id: att._id } }, { doc: { [buildRefRelationKey(RELATION_INDICATES)]: null } }, ]; }) diff --git a/opencti-platform/opencti-graphql/src/migrations/1612999232704-fix_attack_patterns.js b/opencti-platform/opencti-graphql/src/migrations/1612999232704-fix_attack_patterns.js index 89758ec22d11..52d92ef66c02 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1612999232704-fix_attack_patterns.js +++ b/opencti-platform/opencti-graphql/src/migrations/1612999232704-fix_attack_patterns.js @@ -15,7 +15,7 @@ export const up = async (next) => { const op = attacks .map((att) => { return [ - { update: { _index: att._index, _id: att.id } }, + { update: { _index: att._index, _id: att._id } }, { doc: { aliases: [], i_aliases_ids: [], x_opencti_stix_ids: [] } }, ]; }) diff --git a/opencti-platform/opencti-graphql/src/migrations/1613150325865-clear_aliases.js b/opencti-platform/opencti-graphql/src/migrations/1613150325865-clear_aliases.js index 020e33b88967..7f092e214238 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1613150325865-clear_aliases.js +++ b/opencti-platform/opencti-graphql/src/migrations/1613150325865-clear_aliases.js @@ -15,7 +15,7 @@ export const up = async (next) => { const op = attacks .map((att) => { return [ - { update: { _index: att._index, _id: att.id } }, + { update: { _index: att._index, _id: att._id } }, { doc: { aliases: [], i_aliases_ids: [], x_opencti_stix_ids: [] } }, ]; }) diff --git a/opencti-platform/opencti-graphql/src/migrations/1614942944848-fix_locations_identities.js b/opencti-platform/opencti-graphql/src/migrations/1614942944848-fix_locations_identities.js index 1d49ddbaf5e9..49a9e3192127 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1614942944848-fix_locations_identities.js +++ b/opencti-platform/opencti-graphql/src/migrations/1614942944848-fix_locations_identities.js @@ -17,7 +17,7 @@ export const up = async (next) => { .map((att) => { const newId = generateStandardId(att.entity_type, att); return [ - { update: { _index: att._index, _id: att.id } }, + { update: { _index: att._index, _id: att._id } }, { doc: { standard_id: newId, x_opencti_stix_ids: [] } }, ]; }) diff --git a/opencti-platform/opencti-graphql/src/migrations/1616890781521-fix_aliases.js b/opencti-platform/opencti-graphql/src/migrations/1616890781521-fix_aliases.js index 935d4191cf6e..a7790acc5eee 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1616890781521-fix_aliases.js +++ b/opencti-platform/opencti-graphql/src/migrations/1616890781521-fix_aliases.js @@ -33,7 +33,7 @@ export const up = async (next) => { identity_class: entity.identity_class === 'sector' ? 'class' : entity.identity_class, }); return [ - { update: { _index: entity._index, _id: entity.id } }, + { update: { _index: entity._index, _id: entity._id } }, { doc: { i_aliases_ids: newAliasIds, @@ -48,7 +48,7 @@ export const up = async (next) => { const newAliasIds = generateAliases([entity.name, ...(entity.x_opencti_aliases || [])], { x_opencti_location_type: entity.x_opencti_location_type, }); - return [{ update: { _index: entity._index, _id: entity.id } }, { doc: { i_aliases_ids: newAliasIds } }]; + return [{ update: { _index: entity._index, _id: entity._id } }, { doc: { i_aliases_ids: newAliasIds } }]; }) .flat(); bulkOperations.push(...op); diff --git a/opencti-platform/opencti-graphql/src/migrations/1619270898754-migrate_incidents.js b/opencti-platform/opencti-graphql/src/migrations/1619270898754-migrate_incidents.js index 83196a49e024..5f2f5c97f64d 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1619270898754-migrate_incidents.js +++ b/opencti-platform/opencti-graphql/src/migrations/1619270898754-migrate_incidents.js @@ -17,7 +17,7 @@ export const up = async (next) => { .map((entity) => { const newStandardId = generateStandardId(ENTITY_TYPE_INCIDENT, entity); return [ - { update: { _index: entity._index, _id: entity.id } }, + { update: { _index: entity._index, _id: entity._id } }, { doc: { // Fix bad fields diff --git a/opencti-platform/opencti-graphql/src/migrations/1620980638439-fix_attack_patterns.js b/opencti-platform/opencti-graphql/src/migrations/1620980638439-fix_attack_patterns.js index 89758ec22d11..52d92ef66c02 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1620980638439-fix_attack_patterns.js +++ b/opencti-platform/opencti-graphql/src/migrations/1620980638439-fix_attack_patterns.js @@ -15,7 +15,7 @@ export const up = async (next) => { const op = attacks .map((att) => { return [ - { update: { _index: att._index, _id: att.id } }, + { update: { _index: att._index, _id: att._id } }, { doc: { aliases: [], i_aliases_ids: [], x_opencti_stix_ids: [] } }, ]; }) diff --git a/opencti-platform/opencti-graphql/src/migrations/1630337822820-report_status.js b/opencti-platform/opencti-graphql/src/migrations/1630337822820-report_status.js index 743e4bfeb773..b85c5e336773 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1630337822820-report_status.js +++ b/opencti-platform/opencti-graphql/src/migrations/1630337822820-report_status.js @@ -52,7 +52,7 @@ export const up = async (next) => { default: status = workflowStatusClosed; } - return [{ update: { _index: report._index, _id: report.id } }, { doc: { status_id: status.id } }]; + return [{ update: { _index: report._index, _id: report._id } }, { doc: { status_id: status.id } }]; }) .flat(); bulkOperations.push(...op); diff --git a/opencti-platform/opencti-graphql/src/migrations/1637328713848-system_standard_id.js b/opencti-platform/opencti-graphql/src/migrations/1637328713848-system_standard_id.js index aefb4c0b0570..cbb46c306849 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1637328713848-system_standard_id.js +++ b/opencti-platform/opencti-graphql/src/migrations/1637328713848-system_standard_id.js @@ -17,7 +17,7 @@ export const up = async (next) => { .map((att) => { const newId = generateStandardId(att.entity_type, att); return [ - { update: { _index: att._index, _id: att.id } }, + { update: { _index: att._index, _id: att._id } }, { doc: { standard_id: newId, x_opencti_stix_ids: [] } }, ]; }) diff --git a/opencti-platform/opencti-graphql/src/migrations/1716392968110-alias_migration.js b/opencti-platform/opencti-graphql/src/migrations/1716392968110-alias_migration.js index ca3535bf10d9..a8078bd3d9b3 100644 --- a/opencti-platform/opencti-graphql/src/migrations/1716392968110-alias_migration.js +++ b/opencti-platform/opencti-graphql/src/migrations/1716392968110-alias_migration.js @@ -23,7 +23,7 @@ export const up = async (next) => { const bulkOperations = entities.map((entity) => { const aliasIds = generateAliasesIdsForInstance(entity); return [ - { update: { _index: entity._index, _id: entity.id } }, + { update: { _index: entity._index, _id: entity._id } }, { doc: { [iAliasedIds.name]: aliasIds } }, ]; }).flat();