Summary
Apply SetOrdered(false) + mongo.BulkWriteException handling to the Go agent vector store sample, matching the bulk insert patterns already used by Python, TypeScript, .NET, and the non-agent Go sample.
What to change
In InsertHotelsWithEmbeddings method:
- Add
options.InsertMany().SetOrdered(false) for parallel execution
- Handle
mongo.BulkWriteException for partial insert tracking
- Log partial successes instead of failing on first error
Pattern to follow (from existing Go non-agent sample):
result, err := collection.InsertMany(ctx, documents, options.InsertMany().SetOrdered(false))
Go agent equivalent:
opts := options.InsertMany().SetOrdered(false)
result, err := vs.collection.InsertMany(ctx, docs, opts)
if err != nil {
if bulkErr, ok := err.(mongo.BulkWriteException); ok {
inserted := len(docs) - len(bulkErr.WriteErrors)
// Track partial success, only fail if all documents failed
}
}
Files to modify
ai/vector-search-agent-go/internal/vectorstore/store.go
Background
Summary
Apply
SetOrdered(false)+mongo.BulkWriteExceptionhandling to the Go agent vector store sample, matching the bulk insert patterns already used by Python, TypeScript, .NET, and the non-agent Go sample.What to change
In
InsertHotelsWithEmbeddingsmethod:options.InsertMany().SetOrdered(false)for parallel executionmongo.BulkWriteExceptionfor partial insert trackingPattern to follow (from existing Go non-agent sample):
Go agent equivalent:
Files to modify
ai/vector-search-agent-go/internal/vectorstore/store.goBackground