Documentation
¶
Overview ¶
Package massengine provides the official Go client SDK for the MassEngine filtered vector search REST API.
Index ¶
- Constants
- type APIError
- type BatchSearchResponse
- type Client
- func (c *Client) BatchGetDocs(ctx context.Context, tenant string, ids []string, database ...string) ([]DocResponse, error)
- func (c *Client) BatchSearch(ctx context.Context, queries []SearchRequest, database ...string) (*BatchSearchResponse, error)
- func (c *Client) Compact(ctx context.Context) error
- func (c *Client) CreateDatabase(ctx context.Context, tenant string, cfg DatabaseConfig) (*DatabaseInfo, error)
- func (c *Client) CreateTenantKey(ctx context.Context, tenant, key string) (string, error)
- func (c *Client) DeleteDatabase(ctx context.Context, tenant, database string) (int, error)
- func (c *Client) DeleteDoc(ctx context.Context, tenant, id string, database ...string) error
- func (c *Client) DeleteTenant(ctx context.Context, tenant string) (int, error)
- func (c *Client) ExportTenant(ctx context.Context, tenant string, database ...string) ([]Doc, error)
- func (c *Client) Flush(ctx context.Context) error
- func (c *Client) GetDatabase(ctx context.Context, tenant, database string) (*DatabaseInfo, error)
- func (c *Client) GetDoc(ctx context.Context, tenant, id string, database ...string) (*DocResponse, error)
- func (c *Client) GetTenant(ctx context.Context, tenant string, database ...string) (*TenantSummary, error)
- func (c *Client) GetTenantQuota(ctx context.Context, tenant string) (*TenantQuota, error)
- func (c *Client) GetTenantUsage(ctx context.Context, tenant string) (*TenantUsage, error)
- func (c *Client) GoString() string
- func (c *Client) Health(ctx context.Context) (bool, error)
- func (c *Client) ImportTenant(ctx context.Context, tenant string, docs []Doc, database ...string) (int, error)
- func (c *Client) Ingest(ctx context.Context, tenant string, docs []Doc, database ...string) (*IngestResponse, error)
- func (c *Client) IngestDatabase(ctx context.Context, tenant, database string, docs []Doc) (*IngestResponse, error)
- func (c *Client) ListDatabases(ctx context.Context, tenant string) ([]DatabaseInfo, error)
- func (c *Client) ListTenants(ctx context.Context) ([]TenantSummary, error)
- func (c *Client) ListUsage(ctx context.Context) (*UsageReport, error)
- func (c *Client) PatchDoc(ctx context.Context, tenant, id string, req PatchRequest, database ...string) (*DocResponse, error)
- func (c *Client) Ready(ctx context.Context) (*ReadyStatus, error)
- func (c *Client) RevokeTenantKey(ctx context.Context, tenant, key string) error
- func (c *Client) Search(ctx context.Context, req SearchRequest) (*SearchResponse, error)
- func (c *Client) SetTenantQuota(ctx context.Context, tenant string, quota TenantQuota) (*TenantQuota, error)
- func (c *Client) String() string
- type DatabaseConfig
- type DatabaseInfo
- type Doc
- type DocResponse
- type Hit
- type IngestResponse
- type LatencyBucket
- type LatencyStats
- type Options
- type PatchRequest
- type ReadyStatus
- type SearchRequest
- type SearchResponse
- type TenantQuota
- type TenantSummary
- type TenantUsage
- type UsageReport
Constants ¶
const (
// Version is the semantic version of this SDK release.
Version = "1.1.4"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchSearchResponse ¶
type BatchSearchResponse struct {
Results []SearchResponse `json:"results"`
}
BatchSearchResponse is returned by BatchSearch.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the official Go SDK client for the MassEngine HTTP REST API.
func New ¶
New constructs a MassEngine client. If opts contains an invalid BaseURL or APIKey, all subsequent requests on the returned Client fail immediately with that validation error without making network calls.
func NewClient ¶
NewClient constructs and validates a MassEngine client, returning an error if BaseURL or APIKey is invalid.
func (*Client) BatchGetDocs ¶
func (c *Client) BatchGetDocs(ctx context.Context, tenant string, ids []string, database ...string) ([]DocResponse, error)
BatchGetDocs fetches multiple documents by ID in a single request, optionally scoped to database.
func (*Client) BatchSearch ¶
func (c *Client) BatchSearch(ctx context.Context, queries []SearchRequest, database ...string) (*BatchSearchResponse, error)
BatchSearch executes multiple dense vector queries in a single round-trip, with an optional batch-level default database name.
func (*Client) CreateDatabase ¶ added in v1.1.4
func (c *Client) CreateDatabase(ctx context.Context, tenant string, cfg DatabaseConfig) (*DatabaseInfo, error)
CreateDatabase creates or updates a named database under tenant (or under the bound mk_... key's tenant when tenant is empty).
func (*Client) CreateTenantKey ¶
CreateTenantKey registers (or generates if key is empty) a tenant-scoped bearer API key. Requires the admin API key.
func (*Client) DeleteDatabase ¶ added in v1.1.4
DeleteDatabase purges all documents and routing state for a named database.
func (*Client) DeleteTenant ¶
DeleteTenant deletes all documents and state for tenant.
func (*Client) ExportTenant ¶
func (c *Client) ExportTenant(ctx context.Context, tenant string, database ...string) ([]Doc, error)
ExportTenant streams all live documents belonging to tenant (or the bound mk_... key's tenant when tenant is empty) via NDJSON, optionally filtered to a single database.
func (*Client) GetDatabase ¶ added in v1.1.4
GetDatabase fetches metadata and volume statistics for a single named database.
func (*Client) GetDoc ¶
func (c *Client) GetDoc(ctx context.Context, tenant, id string, database ...string) (*DocResponse, error)
GetDoc fetches a document's metadata by ID, optionally scoped to database.
func (*Client) GetTenant ¶
func (c *Client) GetTenant(ctx context.Context, tenant string, database ...string) (*TenantSummary, error)
GetTenant returns volume metadata for a single tenant (or database when optional database is specified).
func (*Client) GetTenantQuota ¶
GetTenantQuota retrieves the active quota configuration for tenant.
func (*Client) GetTenantUsage ¶
GetTenantUsage returns cumulative billable read/write counters, byte footprint, and search latency percentiles for tenant.
func (*Client) GoString ¶
GoString returns a redacted Go-syntax representation that never exposes credentials.
func (*Client) ImportTenant ¶
func (c *Client) ImportTenant(ctx context.Context, tenant string, docs []Doc, database ...string) (int, error)
ImportTenant streams a slice of documents as NDJSON into tenant (or the bound mk_... key's tenant when tenant is empty), optionally scoped to database.
func (*Client) Ingest ¶
func (c *Client) Ingest(ctx context.Context, tenant string, docs []Doc, database ...string) (*IngestResponse, error)
Ingest writes or upserts a batch of documents for tenant (or the tenant bound to a tenant-scoped mk_... API key when tenant is empty), with an optional target database name.
func (*Client) IngestDatabase ¶ added in v1.1.4
func (c *Client) IngestDatabase(ctx context.Context, tenant, database string, docs []Doc) (*IngestResponse, error)
IngestDatabase writes or upserts a batch of documents into the specified database for tenant (or into the bound mk_... key's tenant when tenant is empty).
func (*Client) ListDatabases ¶ added in v1.1.4
ListDatabases lists all databases configured under tenant (or under the bound mk_... key's tenant when tenant is empty).
func (*Client) ListTenants ¶
func (c *Client) ListTenants(ctx context.Context) ([]TenantSummary, error)
ListTenants lists all known tenants.
func (*Client) ListUsage ¶
func (c *Client) ListUsage(ctx context.Context) (*UsageReport, error)
ListUsage returns the cluster-wide usage report across all tenants. Requires the admin API key.
func (*Client) PatchDoc ¶
func (c *Client) PatchDoc(ctx context.Context, tenant, id string, req PatchRequest, database ...string) (*DocResponse, error)
PatchDoc updates an existing document's metadata, date, or category in place without re-supplying its vector.
func (*Client) Ready ¶
func (c *Client) Ready(ctx context.Context) (*ReadyStatus, error)
Ready checks service readiness. Both HTTP 200 and HTTP 503 JSON readiness payloads return a populated ReadyStatus without an error.
func (*Client) RevokeTenantKey ¶
RevokeTenantKey revokes a tenant-scoped bearer API key. Requires the admin API key.
func (*Client) Search ¶
func (c *Client) Search(ctx context.Context, req SearchRequest) (*SearchResponse, error)
Search executes a single dense vector query with optional metadata, date, and category filters.
func (*Client) SetTenantQuota ¶
func (c *Client) SetTenantQuota(ctx context.Context, tenant string, quota TenantQuota) (*TenantQuota, error)
SetTenantQuota configures a tenant's plan tier, MaxDocs/MaxBytes caps, MaxQPS limit, and suspension state. Requires the admin API key.
type DatabaseConfig ¶ added in v1.1.4
type DatabaseConfig struct {
Database string `json:"database"`
NumShards int `json:"num_shards,omitempty"`
RF int `json:"rf,omitempty"`
Mode string `json:"mode,omitempty"`
DataType string `json:"data_type,omitempty"`
}
DatabaseConfig specifies configuration options when creating or updating a named database within a tenant.
type DatabaseInfo ¶ added in v1.1.4
type DatabaseInfo struct {
Tenant string `json:"tenant"`
Database string `json:"database,omitempty"`
Partition string `json:"partition,omitempty"`
Tag uint32 `json:"tag,omitempty"`
Mode string `json:"mode,omitempty"`
PinnedShard int `json:"pinned_shard"`
NumShards int `json:"num_shards,omitempty"`
RF int `json:"rf,omitempty"`
DataType string `json:"data_type,omitempty"`
ExplicitShards bool `json:"explicit_shards,omitempty"`
DocCount uint64 `json:"doc_count"`
ByteCount uint64 `json:"byte_count,omitempty"`
}
DatabaseInfo describes a database's routing configuration and storage volume.
type Doc ¶
type Doc struct {
ID string `json:"id"`
Database string `json:"database,omitempty"`
Vector []float32 `json:"vector"`
Date uint16 `json:"date,omitempty"`
Category uint16 `json:"category,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"`
}
Doc represents a document submitted via Ingest or ImportTenant.
type DocResponse ¶
type DocResponse struct {
ID string `json:"id"`
Tenant string `json:"tenant,omitempty"`
Database string `json:"database,omitempty"`
Date uint16 `json:"date,omitempty"`
Category uint16 `json:"category,omitempty"`
Found bool `json:"found"`
Degraded bool `json:"degraded,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"`
}
DocResponse is returned by GetDoc, PatchDoc, and BatchGetDocs.
type Hit ¶
type Hit struct {
ID string `json:"id"`
DocID uint64 `json:"doc_id"`
Score float32 `json:"score"`
Shard int `json:"shard"`
Metadata json.RawMessage `json:"metadata,omitempty"`
}
Hit is a single search result returned by Search or BatchSearch.
type IngestResponse ¶
type IngestResponse struct {
Ingested int `json:"ingested"`
Degraded bool `json:"degraded"`
Database string `json:"database,omitempty"`
}
IngestResponse is returned by Ingest and IngestDatabase.
type LatencyBucket ¶ added in v1.1.4
LatencyBucket represents one cumulative histogram bucket in LatencyStats.
type LatencyStats ¶ added in v1.1.4
type LatencyStats struct {
Count uint64 `json:"count"`
AvgMs float64 `json:"avg_ms"`
P50Ms float64 `json:"p50_ms"`
P95Ms float64 `json:"p95_ms"`
P99Ms float64 `json:"p99_ms"`
Buckets []LatencyBucket `json:"buckets,omitempty"`
}
LatencyStats summarizes search latency percentiles and histogram buckets.
type Options ¶
type Options struct {
BaseURL string
APIKey string
HTTPClient *http.Client
Timeout time.Duration
MaxResponseBytes int64
}
Options configures a MassEngine HTTP Client.
type PatchRequest ¶
type PatchRequest struct {
Database string `json:"database,omitempty"`
Date *uint16 `json:"date,omitempty"`
Category *uint16 `json:"category,omitempty"`
Metadata json.RawMessage `json:"metadata,omitempty"`
ReplaceMeta bool `json:"replace_metadata,omitempty"`
}
PatchRequest specifies an in-place metadata, date, or category update without re-embedding the document vector.
type ReadyStatus ¶
type ReadyStatus struct {
Ready bool `json:"ready"`
}
ReadyStatus is returned by Ready.
type SearchRequest ¶
type SearchRequest struct {
Tenant string `json:"tenant,omitempty"`
Database string `json:"database,omitempty"`
Vector []float32 `json:"vector"`
MetadataFilter map[string]any `json:"metadata_filter,omitempty"`
K int `json:"k"`
Offset int `json:"offset,omitempty"`
MinScore *float32 `json:"min_score,omitempty"`
RerankPool int `json:"rerank_pool,omitempty"`
NProbe int `json:"nprobe,omitempty"`
MinDate *uint16 `json:"min_date,omitempty"`
MaxDate *uint16 `json:"max_date,omitempty"`
Category *uint16 `json:"category,omitempty"`
Categories []uint16 `json:"categories,omitempty"`
}
SearchRequest specifies a dense vector query with optional database scope, metadata/date/category pre-filters, similarity threshold, and pagination offset.
type SearchResponse ¶
SearchResponse is returned by Search.
type TenantQuota ¶
type TenantQuota struct {
Plan string `json:"plan,omitempty"`
MaxDocs uint64 `json:"max_docs,omitempty"`
MaxBytes uint64 `json:"max_bytes,omitempty"`
MaxQPS float64 `json:"max_qps,omitempty"`
Burst int `json:"burst,omitempty"`
Suspended bool `json:"suspended,omitempty"`
}
TenantQuota defines a tenant's plan tier, document and byte capacity limits, QPS rate limit, and billing suspension state.
type TenantSummary ¶
type TenantSummary struct {
Tenant string `json:"tenant"`
Database string `json:"database,omitempty"`
Partition string `json:"partition,omitempty"`
Mode string `json:"mode,omitempty"`
PinnedShard int `json:"pinned_shard,omitempty"`
NumShards int `json:"num_shards,omitempty"`
RF int `json:"rf,omitempty"`
DataType string `json:"data_type,omitempty"`
DocCount uint64 `json:"doc_count"`
ByteCount uint64 `json:"byte_count,omitempty"`
}
TenantSummary describes a tenant's document and storage volume.
type TenantUsage ¶
type TenantUsage struct {
Tenant string `json:"tenant"`
Plan string `json:"plan,omitempty"`
Suspended bool `json:"suspended,omitempty"`
PartitionCount int `json:"partition_count"`
LiveDocs uint64 `json:"live_docs"`
LiveBytes uint64 `json:"live_bytes"`
MaxDocs uint64 `json:"max_docs,omitempty"`
MaxBytes uint64 `json:"max_bytes,omitempty"`
MaxQPS float64 `json:"max_qps,omitempty"`
ReadRequests uint64 `json:"read_requests"`
ReadUnits uint64 `json:"read_units"`
WriteRequests uint64 `json:"write_requests"`
WriteUnits uint64 `json:"write_units"`
RateLimited uint64 `json:"rate_limited"`
SearchLatency LatencyStats `json:"search_latency"`
UpdatedAt string `json:"updated_at,omitempty"`
}
TenantUsage reports cumulative billable read/write counters, logical byte footprint, and search latency percentiles for a single tenant.
type UsageReport ¶
type UsageReport struct {
Tenants []TenantUsage `json:"tenants"`
TotalLiveDocs uint64 `json:"total_live_docs"`
TotalLiveBytes uint64 `json:"total_live_bytes"`
TotalReadUnits uint64 `json:"total_read_units"`
TotalWriteUnits uint64 `json:"total_write_units"`
}
UsageReport aggregates per-tenant usage across the cluster.