Loads an existing encrypted index by name and key. The provided key must match the one used during index creation.
func (c *Client) LoadIndex(ctx context.Context, indexName string, indexKey []byte) (*EncryptedIndex, error)

Parameters

ParameterTypeDescription
ctxcontext.ContextContext for cancellation/timeouts
indexNamestringName of the existing index to load
indexKey[]byte32-byte encryption key used during index creation
The encryption key must exactly match the key used during index creation.

Returns

TypeDescription
*EncryptedIndexHandle for performing vector operations on the loaded index
errorAny error encountered during index loading

Exceptions

Example Usage

package main

import (
    "context"
    "encoding/hex"
    "log"
    
    "github.com/cyborginc/cyborgdb-go"
)

func main() {
    // Create client
    client, err := cyborgdb.NewClient("http://localhost:8000", "your-api-key")
    if err != nil {
        log.Fatal(err)
    }
    
    // Replace with your actual encryption key
    key := []byte("example-index-key-1234567890")
    
    // Load existing index
    ctx := context.Background()
    index, err := client.LoadIndex(ctx, "my-documents", key)
    if err != nil {
        log.Fatal("Failed to load index:", err)
    }
    
    log.Printf("Loaded index: %s", index.GetIndexName())
    log.Printf("Index type: %s", index.GetIndexType())
    log.Printf("Is trained: %t", index.IsTrained())
}