Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.cyborg.co/llms.txt

Use this file to discover all available pages before exploring further.

Removes vectors from the index by their IDs. This operation permanently deletes the specified vectors and their associated data.
func (e *EncryptedIndex) Delete(ctx context.Context, ids []string) error

Parameters

ParameterTypeDescription
ctxcontext.ContextContext for cancellation and timeouts
ids[]stringSlice of vector IDs to delete

Error Handling

  • Returns error if the API request fails due to network connectivity issues
  • Returns error if authentication fails (invalid API key)
  • Returns error if the encryption key is invalid for the specified index
  • Returns error if there are internal server errors during deletion
  • Returns error if the IDs slice is empty
  • The operation succeeds even if some IDs don’t exist in the index

Example Usage

package main

import (
    "context"
    "encoding/hex"
    "fmt"
    "log"

    "github.com/cyborginc/cyborgdb-go"
)

func main() {
    client, err := cyborgdb.NewClient("http://localhost:8000", "your-api-key")
    if err != nil {
        log.Fatal(err)
    }

    // Load an existing index
    indexKeyHex := "your-64-character-hex-key-here"
    indexKey, err := hex.DecodeString(indexKeyHex)
    if err != nil {
        log.Fatal(err)
    }

    index, err := client.LoadIndex(context.Background(), "my-vector-index", indexKey)
    if err != nil {
        log.Fatal(err)
    }

    // Delete specific vectors by ID
    ids := []string{"doc1", "doc2", "doc3"}

    err = index.Delete(context.Background(), ids)
    if err != nil {
        log.Fatalf("Delete failed: %v", err)
    }

    fmt.Printf("Successfully deleted %d vectors\n", len(ids))
}