Documentation
¶
Overview ¶
Package massengine provides the official Go client SDK for the MassEngine vector and hybrid search REST API.
Index ¶
- Constants
- type APIError
- type BatchSearchResponse
- type Client
- func (c *Client) BatchGetDocs(ctx context.Context, tenant string, ids []string) ([]DocResponse, error)
- func (c *Client) BatchSearch(ctx context.Context, queries []SearchRequest) (*BatchSearchResponse, error)
- func (c *Client) Compact(ctx context.Context) error
- func (c *Client) CreateTenantKey(ctx context.Context, tenant, key string) (string, error)
- func (c *Client) DeleteDoc(ctx context.Context, tenant, id string) error
- func (c *Client) DeleteTenant(ctx context.Context, tenant string) (int, error)
- func (c *Client) ExportTenant(ctx context.Context, tenant string) ([]Doc, error)
- func (c *Client) Flush(ctx context.Context) error
- func (c *Client) GetDoc(ctx context.Context, tenant, id string) (*DocResponse, error)
- func (c *Client) GetTenant(ctx context.Context, tenant 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) ImportTenant(ctx context.Context, tenant string, docs []Doc) (int, error)
- func (c *Client) Ingest(ctx context.Context, tenant string, docs []Doc) (*IngestResponse, 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) (*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 Doc
- type DocResponse
- type Hit
- type IngestResponse
- 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.2"
)
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) ([]DocResponse, error)
BatchGetDocs fetches multiple documents by ID in a single request.
func (*Client) BatchSearch ¶
func (c *Client) BatchSearch(ctx context.Context, queries []SearchRequest) (*BatchSearchResponse, error)
BatchSearch executes multiple queries in a single round-trip.
func (*Client) CreateTenantKey ¶
CreateTenantKey registers (or generates if key is empty) a tenant-scoped bearer API key. Requires the admin API key.
func (*Client) DeleteTenant ¶
DeleteTenant deletes all documents and state for tenant.
func (*Client) ExportTenant ¶
ExportTenant streams all live documents belonging to tenant via NDJSON.
func (*Client) GetTenantQuota ¶
GetTenantQuota retrieves the active quota configuration for tenant.
func (*Client) GetTenantUsage ¶
GetTenantUsage returns cumulative billable read/write counters and capacity utilization for tenant.
func (*Client) GoString ¶
GoString returns a redacted Go-syntax representation that never exposes credentials.
func (*Client) ImportTenant ¶
ImportTenant streams a slice of documents as NDJSON into tenant.
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) (*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.
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 vector, lexical, or hybrid query.
func (*Client) SetTenantQuota ¶
func (c *Client) SetTenantQuota(ctx context.Context, tenant string, quota TenantQuota) (*TenantQuota, error)
SetTenantQuota configures a tenant's plan tier, MaxDocs cap, MaxQPS limit, and suspension state. Requires the admin API key.
type Doc ¶
type Doc struct {
ID string `json:"id"`
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"`
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 ¶
IngestResponse is returned by Ingest.
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 {
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"`
Vector []float32 `json:"vector,omitempty"`
QueryText string `json:"query_text,omitempty"`
HybridAlpha float32 `json:"hybrid_alpha,omitempty"`
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 vector, lexical, or hybrid query with optional 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"`
MaxQPS float64 `json:"max_qps,omitempty"`
Burst int `json:"burst,omitempty"`
Suspended bool `json:"suspended,omitempty"`
}
TenantQuota defines a tenant's plan tier, document capacity limit, QPS rate limit, and billing suspension state.
type TenantSummary ¶
type TenantSummary struct {
Tenant string `json:"tenant"`
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"`
LiveDocs uint64 `json:"live_docs"`
MaxDocs uint64 `json:"max_docs,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"`
UpdatedAt string `json:"updated_at,omitempty"`
}
TenantUsage reports cumulative billable read/write counters and capacity utilization for a single tenant.
type UsageReport ¶
type UsageReport struct {
Tenants []TenantUsage `json:"tenants"`
TotalLiveDocs uint64 `json:"total_live_docs"`
TotalReadUnits uint64 `json:"total_read_units"`
TotalWriteUnits uint64 `json:"total_write_units"`
}
UsageReport aggregates per-tenant usage across the cluster.