Go Types
The Endee Go SDK provides idiomatic Go types with exported struct fields and constants. This page documents all available types, constants, and structs.
Imports
Import the package:
import "github.com/endee-io/endee-go-client"All types and constants are accessed via the endee package prefix (e.g., endee.VectorItem, endee.PrecisionFloat32).
Constants
Precision Types
Defines the quantization precision levels for vector storage and search.
const (
PrecisionBinary = "binary" // 1-bit binary quantization
PrecisionFloat16 = "float16" // 16-bit floating point
PrecisionFloat32 = "float32" // 32-bit floating point
PrecisionInt16D = "int16d" // 16-bit integer quantization
PrecisionInt8D = "int8d" // 8-bit integer quantization
)| Value | Description |
|---|---|
PrecisionBinary | Binary quantization (1-bit) - smallest storage, fastest search |
PrecisionInt8D | 8-bit integer quantization - balanced performance |
PrecisionInt16D | 16-bit integer quantization - higher precision |
PrecisionFloat16 | 16-bit floating point - good balance |
PrecisionFloat32 | 32-bit floating point - highest precision |
Usage:
err := client.CreateIndex("my_index", 384, "cosine", 16, 128, endee.PrecisionInt8D, nil, 0)Distance Metrics
Defines the distance metric used for similarity calculations.
const (
Cosine = "cosine" // Cosine similarity
L2 = "l2" // Euclidean distance
InnerProduct = "ip" // Inner product
)| Value | Description |
|---|---|
Cosine | Cosine similarity - measures angle between vectors |
L2 | Euclidean distance - measures straight-line distance |
InnerProduct | Inner product - measures dot product similarity |
Limits
Maximum allowed values for various parameters.
const (
MaxDimensionAllowed = 10000 // Maximum vector dimensionality
MaxVectorsPerBatch = 1000 // Maximum vectors per upsert
MaxTopKAllowed = 512 // Maximum top-k results
MaxEfSearchAllowed = 1024 // Maximum ef parameter
MaxIndexNameLenAllowed = 48 // Maximum index name length
)| Constant | Value | Description |
|---|---|---|
MaxDimensionAllowed | 10000 | Maximum vector dimensionality |
MaxVectorsPerBatch | 1000 | Maximum vectors per upsert call |
MaxTopKAllowed | 512 | Maximum top-k results per query |
MaxEfSearchAllowed | 1024 | Maximum ef search parameter |
MaxIndexNameLenAllowed | 48 | Maximum index name length |
Defaults
Default parameter values used when not explicitly specified.
const (
DefaultM = 16 // Default HNSW M parameter
DefaultEfConstruction = 128 // Default ef_construction
DefaultTopK = 10 // Default top-k
DefaultEfSearch = 128 // Default ef_search
)| Constant | Value | Description |
|---|---|---|
DefaultM | 16 | Default HNSW graph connectivity parameter |
DefaultEfConstruction | 128 | Default construction-time quality parameter |
DefaultTopK | 10 | Default number of results per query |
DefaultEfSearch | 128 | Default runtime search parameter |
Structs
VectorItem
Represents a vector to be upserted into an index.
type VectorItem struct {
ID string `json:"id"`
Vector []float32 `json:"vector"`
Meta map[string]interface{} `json:"meta,omitempty"`
Filter map[string]interface{} `json:"filter,omitempty"`
}| Field | Type | Required | Description |
|---|---|---|---|
ID | string | Yes | Unique identifier for the vector |
Vector | []float32 | Yes | Dense embedding vector |
Meta | map[string]interface{} | No | Arbitrary metadata map |
Filter | map[string]interface{} | No | Key-value pairs for filtering during queries |
Example:
vectors := []endee.VectorItem{
{
ID: "doc1",
Vector: []float32{0.1, 0.2, 0.3},
Meta: map[string]interface{}{"title": "Document 1"},
Filter: map[string]interface{}{"category": "tech"},
},
{
ID: "doc2",
Vector: []float32{0.4, 0.5, 0.6},
Meta: map[string]interface{}{"title": "Document 2"},
Filter: map[string]interface{}{"visibility": "public"},
},
}
index.Upsert(vectors)QueryResult
Represents a single result from a query.
type QueryResult struct {
ID string `json:"id"`
Similarity float32 `json:"similarity"`
Distance float32 `json:"distance"`
Meta map[string]interface{} `json:"meta"`
Filter map[string]interface{} `json:"filter,omitempty"`
Norm float32 `json:"norm"`
Vector []float32 `json:"vector,omitempty"`
}| Field | Type | Description |
|---|---|---|
ID | string | Vector identifier |
Similarity | float32 | Similarity score (higher is more similar) |
Distance | float32 | Distance value (1 - similarity) |
Meta | map[string]interface{} | Metadata attached to the vector |
Filter | map[string]interface{} | Filter fields attached to the vector |
Norm | float32 | Normalization factor |
Vector | []float32 | Vector data (only if includeVectors was true) |
Example:
results, err := index.Query(queryVector, nil, nil, 5, nil, 128, false)
if err != nil {
log.Fatal(err)
}
for _, result := range results {
fmt.Printf("ID: %s\n", result.ID)
fmt.Printf("Similarity: %.3f\n", result.Similarity)
fmt.Printf("Distance: %.3f\n", result.Distance)
fmt.Printf("Meta: %+v\n", result.Meta)
}Client and Index Types
Endee (Client)
The main client type returned by EndeeClient(). Provides methods for managing indexes.
| Method | Return Type | Description |
|---|---|---|
CreateIndex(...) | error | Create a new vector index |
CreateIndexWithContext(ctx, ...) | error | Create index with context support |
ListIndexes() | ([]interface{}, error) | List all indexes |
ListIndexesWithContext(ctx) | ([]interface{}, error) | List indexes with context support |
DeleteIndex(name) | error | Delete an index |
DeleteIndexWithContext(ctx, name) | error | Delete index with context support |
GetIndex(name) | (*Index, error) | Get reference to an index |
GetIndexWithContext(ctx, name) | (*Index, error) | Get index with context support |
Properties:
| Property | Type | Description |
|---|---|---|
BaseUrl | string | Base URL for the Endee server (default: http://localhost:8080/api/v1) |
Index
The Index type is returned by client.GetIndex() and provides methods for vector operations.
| Method | Return Type | Description |
|---|---|---|
Upsert(vectors) | error | Insert or update vectors |
UpsertWithContext(ctx, vectors) | error | Upsert with context support |
Query(vector, sparseIndices, sparseValues, k, filter, ef, includeVectors) | ([]QueryResult, error) | Search for similar vectors |
QueryWithContext(ctx, ...) | ([]QueryResult, error) | Query with context support |
DeleteVectorById(id) | (string, error) | Delete a vector by ID |
DeleteVectorByIdWithContext(ctx, id) | (string, error) | Delete vector with context |
DeleteVectorByFilter(filter) | (string, error) | Delete vectors matching a filter |
DeleteVectorByFilterWithContext(ctx, filter) | (string, error) | Delete by filter with context |
DeleteHybridVectorById(id) | (string, error) | Delete a hybrid vector by ID |
DeleteHybridVectorByIdWithContext(ctx, id) | (string, error) | Delete hybrid vector with context |
DeleteHybridVectorByFilter(filter) | (string, error) | Delete hybrid vectors by filter |
DeleteHybridVectorByFilterWithContext(ctx, filter) | (string, error) | Delete hybrid by filter with context |
GetVector(id) | (VectorItem, error) | Get a vector by ID |
GetVectorWithContext(ctx, id) | (VectorItem, error) | Get vector with context |
GetInfo() | string | Get index statistics and configuration |
String() | string | Get string representation of index |
Type Summary
| Type | Kind | Description |
|---|---|---|
VectorItem | Struct | Vector for upserting |
QueryResult | Struct | Single query result |
Endee | Client | Main client for index management |
Index | Client | Index-level vector operations |
| Precision constants | Constants | Quantization precision levels |
| Distance metrics | Constants | Distance metric options |
| Limits | Constants | Maximum parameter values |
| Defaults | Constants | Default parameter values |