Skip to content

Commit

Permalink
[backend] Fix usage of ElasticSearch ID
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelHassine committed Jan 27, 2025
1 parent e588de5 commit eda09e4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions opencti-platform/opencti-graphql/src/database/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -4121,7 +4121,7 @@ export const elIndexElements = async (context, user, indexingType, elements) =>
return { ...entity, id: entityId, data: { script: { source, params } } };
});
const bodyUpdate = elementsToUpdate.flatMap((doc) => [
{ update: { _index: doc._index, _id: doc._id ?? doc.internal_id, retry_on_conflict: ES_RETRY_ON_CONFLICT } },
{ update: { _index: doc._index, _id: doc._id ?? doc.id, retry_on_conflict: ES_RETRY_ON_CONFLICT } },
R.dissoc('_index', doc.data),
]);
if (bodyUpdate.length > 0) {
Expand All @@ -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 ?? doc.internal_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 });
Expand Down Expand Up @@ -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 ?? doc.internal_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,
Expand Down

0 comments on commit eda09e4

Please sign in to comment.