Repository: FlowiseAI/Flowise
File: packages/components/nodes/vectorstores/Qdrant/Qdrant.ts (TypeScript)

Code before:
                            try {
                                client.delete(collectionName, {
                                    points: ids
                                })
                            } catch (e) {
                                console.error('Failed to delete')
                            }
                        }
                    }

                    await recordManager.createSchema()

                    const res = await index({
                        docsSource: finalDocs,
                        recordManager,
                        vectorStore,
                        options: {
                            cleanup: recordManager?.cleanup,
                            sourceIdKey: recordManager?.sourceIdKey ?? 'source',
                            vectorStoreName: collectionName
                        }
                    })

                    return res
                } else {
                    for(let i=0; i<finalDocs.length; i+=batchSize) {
                        const batch = finalDocs.slice(i, i+batchSize)
                        await QdrantVectorStore.fromDocuments(batch, embeddings, dbConfig)
                    }
                    return { numAdded: finalDocs.length, addedDocs: finalDocs }
                }
            } catch (e) {
                throw new Error(e)
            }
        }
    }

    async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
        const qdrantServerUrl = nodeData.inputs?.qdrantServerUrl as string
        const collectionName = nodeData.inputs?.qdrantCollection as string
        let qdrantCollectionConfiguration = nodeData.inputs?.qdrantCollectionConfiguration
        const embeddings = nodeData.inputs?.embeddings as Embeddings
        const qdrantSimilarity = nodeData.inputs?.qdrantSimilarity
        const qdrantVectorDimension = nodeData.inputs?.qdrantVectorDimension
        const output = nodeData.outputs?.output as string
        const topK = nodeData.inputs?.topK as string
        let queryFilter = nodeData.inputs?.qdrantFilter

        const k = topK ? parseFloat(topK) : 4

        const credentialData = await getCredentialData(nodeData.credential ?? '', options)

Review comment (performance):
if no `batchSize` is found, can we just do it without for loop?

I tried upserting 1k+ chunks, it works fine:
![image](https://github.com/FlowiseAI/Flowise/assets/26460777/b71a3038-5722-4a5f-820d-faf620a7d730)

Instead of doing this 10 times in for loop, I think its better for other to specify the batch size once they faced the error, if everything works fine for the first try, then thats great

Code after:
                                    points
                                })
                            }
                        } catch (e: any) {
                            const error = new Error(`${e?.status ?? 'Undefined error code'} ${e?.message}: ${e?.data?.status?.error}`)
                            throw error
                        }
                    }

                    vectorStore.delete = async (params: { ids: string[] }): Promise<void> => {
                        const { ids } = params

                        if (ids?.length) {
                            try {
                                client.delete(collectionName, {
                                    points: ids
                                })
                            } catch (e) {
                                console.error('Failed to delete')
                            }
                        }
                    }

                    await recordManager.createSchema()

                    const res = await index({
                        docsSource: finalDocs,
                        recordManager,
                        vectorStore,
                        options: {
                            cleanup: recordManager?.cleanup,
                            sourceIdKey: recordManager?.sourceIdKey ?? 'source',
                            vectorStoreName: collectionName
                        }
                    })

                    return res
                } else {
                    if (_batchSize) {
                        const batchSize = parseInt(_batchSize, 10)
                        for (let i = 0; i < finalDocs.length; i += batchSize) {
                            const batch = finalDocs.slice(i, i + batchSize)
                            await QdrantVectorStore.fromDocuments(batch, embeddings, dbConfig)
                        }
                    } else {
                        await QdrantVectorStore.fromDocuments(finalDocs, embeddings, dbConfig)
                    }
                    return { numAdded: finalDocs.length, addedDocs: finalDocs }
                }
            } catch (e) {
                throw new Error(e)