Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
mdial89f committed Mar 18, 2024
1 parent 9988959 commit cd95e07
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions src/libs/opensearch-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,7 @@ export async function bulkUpdateData(

client = client || (await getClient(host));

const lastEntries = arrayOfDocuments.reduce(
(acc: { [id: string]: Document }, doc: Document) => {
acc[doc.id] = doc; // This will overwrite any previous entry with the same ID
return acc;
},
{},
);
const filteredDocuments = Object.values(lastEntries);

const body: any[] = filteredDocuments.flatMap((doc) => [
const body: any[] = arrayOfDocuments.flatMap((doc) => [
{ update: { _index: index, _id: doc.id } }, // Action and metadata
{ doc: doc, doc_as_upsert: true }, // Document to update or upsert
]);
Expand Down

0 comments on commit cd95e07

Please sign in to comment.