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.

Retrieves specific vectors from the index by their IDs. This method allows efficient retrieval of vectors and their metadata without performing similarity search.
func (e *EncryptedIndex) Get(ctx context.Context, ids []string, include []string) (*GetResponse, error)

Parameters

ParameterTypeDescription
ctxcontext.ContextContext for cancellation and timeouts
ids[]stringSlice of vector IDs to retrieve
include[]stringFields to include in response: “vector”, “metadata”, “contents”

Returns

  • *GetResponse: Retrieved vectors with requested fields
  • error: Any error encountered, including IDs not found

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 retrieval
  • Returns error if the IDs slice is empty
  • Returns error if any ID is not found in the index
  • Returns error if the include parameter contains invalid field names

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)
    }

    // Retrieve specific vectors by ID
    ids := []string{"doc1", "doc2", "doc3"}
    include := []string{"vector", "metadata"}

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

    fmt.Printf("Retrieved %d vectors:\n", len(results.Results))
    for i, result := range results.Results {
        fmt.Printf("%d. ID: %s\n", i+1, result.Id)

        if result.Metadata != nil {
            fmt.Printf("   Metadata: %v\n", result.Metadata)
        }

        if result.Vector != nil {
            fmt.Printf("   Vector dimensions: %d\n", len(result.Vector))
            fmt.Printf("   Vector preview: [%.3f, %.3f, ...]\n",
                result.Vector[0], result.Vector[1])
        }
    }
}

Response Item Fields

FieldTypeDescription
IdstringVector identifier (always included)
Vector[]float32Vector data (if included)
ContentsstringVector contents (if included)
Metadatamap[string]interface{}Vector metadata (if included)