Skip to content

Commit 985527c

Browse files
fix(server): correct Qdrant batching logic for large uploads (#4545)
* fix(server): correct Qdrant batching logic for large uploads Closes #4544 * modify O(3N) process to O(N) --------- Co-authored-by: timothycarambat <[email protected]>
1 parent 5edc1be commit 985527c

File tree

1 file changed

+22
-12
lines changed
  • server/utils/vectorDbProviders/qdrant

1 file changed

+22
-12
lines changed

server/utils/vectorDbProviders/qdrant/index.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,28 @@ const QDrant = {
276276
const chunks = [];
277277

278278
console.log("Inserting vectorized chunks into QDrant collection.");
279-
for (const chunk of toChunks(vectors, 500)) chunks.push(chunk);
280-
281-
const additionResult = await client.upsert(namespace, {
282-
wait: true,
283-
batch: {
284-
ids: submission.ids,
285-
vectors: submission.vectors,
286-
payloads: submission.payloads,
287-
},
288-
});
289-
if (additionResult?.status !== "completed")
290-
throw new Error("Error embedding into QDrant", additionResult);
279+
for (const chunk of toChunks(vectors, 500)) {
280+
const batchIds = [],
281+
batchVectors = [],
282+
batchPayloads = [];
283+
chunks.push(chunk);
284+
chunk.forEach((v) => {
285+
batchIds.push(v.id);
286+
batchVectors.push(v.vector);
287+
batchPayloads.push(v.payload);
288+
});
289+
290+
const additionResult = await client.upsert(namespace, {
291+
wait: true,
292+
batch: {
293+
ids: batchIds,
294+
vectors: batchVectors,
295+
payloads: batchPayloads,
296+
},
297+
});
298+
if (additionResult?.status !== "completed")
299+
throw new Error("Error embedding into QDrant", additionResult);
300+
}
291301

292302
await storeVectorResult(chunks, fullFilePath);
293303
}

0 commit comments

Comments
 (0)