Skip to Content
Go SDKTypes

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 )
ValueDescription
PrecisionBinaryBinary quantization (1-bit) - smallest storage, fastest search
PrecisionInt8D8-bit integer quantization - balanced performance
PrecisionInt16D16-bit integer quantization - higher precision
PrecisionFloat1616-bit floating point - good balance
PrecisionFloat3232-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 )
ValueDescription
CosineCosine similarity - measures angle between vectors
L2Euclidean distance - measures straight-line distance
InnerProductInner 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 )
ConstantValueDescription
MaxDimensionAllowed10000Maximum vector dimensionality
MaxVectorsPerBatch1000Maximum vectors per upsert call
MaxTopKAllowed512Maximum top-k results per query
MaxEfSearchAllowed1024Maximum ef search parameter
MaxIndexNameLenAllowed48Maximum 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 )
ConstantValueDescription
DefaultM16Default HNSW graph connectivity parameter
DefaultEfConstruction128Default construction-time quality parameter
DefaultTopK10Default number of results per query
DefaultEfSearch128Default 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"` }
FieldTypeRequiredDescription
IDstringYesUnique identifier for the vector
Vector[]float32YesDense embedding vector
Metamap[string]interface{}NoArbitrary metadata map
Filtermap[string]interface{}NoKey-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"` }
FieldTypeDescription
IDstringVector identifier
Similarityfloat32Similarity score (higher is more similar)
Distancefloat32Distance value (1 - similarity)
Metamap[string]interface{}Metadata attached to the vector
Filtermap[string]interface{}Filter fields attached to the vector
Normfloat32Normalization factor
Vector[]float32Vector 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.

MethodReturn TypeDescription
CreateIndex(...)errorCreate a new vector index
CreateIndexWithContext(ctx, ...)errorCreate index with context support
ListIndexes()([]interface{}, error)List all indexes
ListIndexesWithContext(ctx)([]interface{}, error)List indexes with context support
DeleteIndex(name)errorDelete an index
DeleteIndexWithContext(ctx, name)errorDelete index with context support
GetIndex(name)(*Index, error)Get reference to an index
GetIndexWithContext(ctx, name)(*Index, error)Get index with context support

Properties:

PropertyTypeDescription
BaseUrlstringBase 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.

MethodReturn TypeDescription
Upsert(vectors)errorInsert or update vectors
UpsertWithContext(ctx, vectors)errorUpsert 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()stringGet index statistics and configuration
String()stringGet string representation of index

Type Summary

TypeKindDescription
VectorItemStructVector for upserting
QueryResultStructSingle query result
EndeeClientMain client for index management
IndexClientIndex-level vector operations
Precision constantsConstantsQuantization precision levels
Distance metricsConstantsDistance metric options
LimitsConstantsMaximum parameter values
DefaultsConstantsDefault parameter values