Skip to content

[Optimization] Add ordered(false) bulk insert to Go agent sample #62

@diberry

Description

@diberry

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:

  1. Add options.InsertMany().SetOrdered(false) for parallel execution
  2. Handle mongo.BulkWriteException for partial insert tracking
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestsquadSquad managed issuesquad:ashfordAssigned to Ashford (Go Engineer)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions