This action is irreversible. Proceed with caution.
Deletes the current index and all its associated data from the CyborgDB service.
func (e *EncryptedIndex) DeleteIndex(ctx context.Context) error

Parameters

ParameterTypeDescription
ctxcontext.ContextContext for cancellation and timeouts

Error Handling

Example Usage

package main

import (
    "context"
    "fmt"
    "log"

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

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

    // Load the index to be deleted
    indexKey := "your-64-character-hex-key"
    index, err := client.LoadIndex(context.Background(), cyborgdb.LoadIndexParams{
        IndexName: "index-to-delete",
        IndexKey:  indexKey,
    })
    if err != nil {
        log.Fatal(err)
    }

    // Permanently delete the entire index
    fmt.Printf("Deleting index: %s\n", index.GetIndexName())
    err = index.DeleteIndex(context.Background())
    if err != nil {
        log.Fatalf("Failed to delete index: %v", err)
    }

    fmt.Println("Index deleted successfully!")
    // The index handle is now invalid and should not be used
}