Skip to main content
v0.17 removes the GetIndexType and GetIndexConfig methods — there is now a single DiskIVF index type. The Go SDK exposes GetIndexName, IsTrained, IsTraining, and the three describe-backed accessors Dimension, Metric, and NLists.

GetIndexName

Returns the unique name of the index. Known at construction — no API call.
func (e *EncryptedIndex) GetIndexName() string
Returns: string - The index name as specified during creation Example:
indexName := index.GetIndexName()
fmt.Printf("Working with index: %s\n", indexName)

Dimension

Returns the vector dimensionality of the index.
  • Returns the real dimension when CreateIndex was called with an explicit Dimension, or after the first upsert (auto-detect).
  • Returns 0 when the index was created with auto-detect AND no upsert has happened yet.
Each call queries the describe endpoint for live state.
func (e *EncryptedIndex) Dimension(ctx context.Context) (int32, error)
Parameters:
  • ctx: context.Context — context for cancellation and timeouts
Returns:
  • int32 — vector dimension
  • error — any error encountered during the lookup
Example:
dim, err := index.Dimension(context.Background())
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Dimension: %d\n", dim)

Metric

Returns the distance metric used by this index: "euclidean", "squared_euclidean", or "cosine".
func (e *EncryptedIndex) Metric(ctx context.Context) (string, error)
Parameters:
  • ctx: context.Context — context for cancellation and timeouts
Returns:
  • string — the distance metric
  • error — any error encountered during the lookup
Example:
metric, err := index.Metric(context.Background())
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Metric: %s\n", metric)

NLists

Returns the number of inverted lists in the IVF index.
  • Returns 1 for untrained indexes.
  • Returns the trained cluster count after Train completes.
Each call queries the describe endpoint so post-training callers see the updated value.
func (e *EncryptedIndex) NLists(ctx context.Context) (int32, error)
Parameters:
  • ctx: context.Context — context for cancellation and timeouts
Returns:
  • int32 — number of inverted lists
  • error — any error encountered during the lookup
Example:
n, err := index.NLists(context.Background())
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Lists: %d\n", n)

IsTrained

Checks whether the index has been optimized through training. Makes an API call to get the current training status from the server.
func (e *EncryptedIndex) IsTrained(ctx context.Context) (bool, error)
Parameters:
  • ctx: context.Context — context for cancellation and timeouts
Returns:
  • booltrue if the index has been trained, false otherwise
  • error — any error encountered during the status check
Example:
ctx := context.Background()
trained, err := index.IsTrained(ctx)
if err != nil {
    log.Printf("Failed to check training status: %v", err)
    return
}

if trained {
    fmt.Println("Index is trained and optimized")
} else {
    fmt.Println("Index may benefit from training")
    if err := index.Train(ctx, cyborgdb.TrainParams{}); err != nil {
        log.Printf("Training failed: %v", err)
    }
}

IsTraining

Queries the server to check if the index is currently being trained (either actively training or queued).
func (e *EncryptedIndex) IsTraining(ctx context.Context) (bool, error)
Parameters:
  • ctx: context.Context — context for cancellation and timeouts
Returns:
  • booltrue if the index is currently being trained or queued, false otherwise
  • error — any error encountered during the status check
Example:
isTraining, err := index.IsTraining(context.Background())
if err != nil {
    log.Printf("Failed to check training status: %v", err)
    return
}

if isTraining {
    fmt.Println("Index is currently being trained")
    for isTraining {
        time.Sleep(10 * time.Second)
        isTraining, err = index.IsTraining(context.Background())
        if err != nil {
            log.Printf("Error checking training status: %v", err)
            break
        }
    }
    fmt.Println("Training completed!")
}