Documentation
¶
Overview ¶
Package helixgraph adapts HelixDB to brain.GraphReader / GraphWriter / searchers.
Host surface: New / NewFromClient, Bootstrap (preferred boot), EnsureSearchIndexes, EnsureEdgeTextIndex (required per relation label before find_links), Client (escape hatch for host seeding), ObjectSearchReady / TenantEnabled, and the GraphWriter / searcher methods used via brain.WithGraph.
Helix owns topology, text/vector indexes, edge props, and $distance ranking; this package dual-writes props and runs native Helix queries for Engine hydrate. Node labels and property key strings are package-private.
Index ¶
- type Graph
- func (g *Graph) AddEdge(ctx context.Context, from, to uuid.UUID, relationType string, ...) error
- func (g *Graph) Bootstrap(ctx context.Context, withNamespaceTenant bool) error
- func (g *Graph) Client() *helix.Client
- func (g *Graph) EnsureEdgeTextIndex(ctx context.Context, relationLabel string) error
- func (g *Graph) EnsureObject(ctx context.Context, obj brain.Object) error
- func (g *Graph) EnsureSearchIndexes(ctx context.Context, withNamespaceTenant bool) error
- func (g *Graph) Neighbors(ctx context.Context, objectID uuid.UUID, relationTypes []string, limit int) ([]brain.GraphNeighbor, error)
- func (g *Graph) ObjectSearchReady() bool
- func (g *Graph) RemoveEdge(ctx context.Context, from, to uuid.UUID, relationType string) error
- func (g *Graph) RemoveObject(ctx context.Context, id uuid.UUID) error
- func (g *Graph) SearchEdgesText(ctx context.Context, relationLabel, query string, limit int) ([]brain.EdgeSearchHit, error)
- func (g *Graph) SearchText(ctx context.Context, query string, limit int, namespace brain.Namespace) ([]brain.ScoredID, error)
- func (g *Graph) SearchVector(ctx context.Context, embedding []float32, limit int, namespace brain.Namespace) ([]brain.ScoredID, error)
- func (g *Graph) TenantEnabled() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph implements brain.GraphWriter via HelixDB.
func New ¶
func New(baseURL string, opts ...helix.ClientOption) (*Graph, error)
New builds a client. Empty baseURL defaults to http://localhost:6969.
func NewFromClient ¶
NewFromClient uses an existing SDK client.
func (*Graph) AddEdge ¶
func (g *Graph) AddEdge(ctx context.Context, from, to uuid.UUID, relationType string, meta brain.EdgeMeta) error
AddEdge implements brain.GraphWriter via Helix DropEdgeLabeled + AddE (native upsert).
func (*Graph) Bootstrap ¶
Bootstrap prepares Helix native indexes for entity search and marks the graph ready. withNamespaceTenant enables Helix tenant-scoped text/vector indexes on namespace (prefer this when the Helix image supports it so Search* filters in-engine). Call once at process start when using Helix.
func (*Graph) EnsureEdgeTextIndex ¶
EnsureEdgeTextIndex creates a Helix EdgeText index on note for a relation label. Relation labels are dynamic (about, has_buyer, …); hosts call this for labels they search.
func (*Graph) EnsureObject ¶
EnsureObject implements brain.GraphWriter: insert if missing, else update props in place. Incident edges are preserved (never drop+recreate the node identity).
func (*Graph) EnsureSearchIndexes ¶
EnsureSearchIndexes creates Helix native equality + text + vector indexes for find_objects. Prefer Bootstrap, which also sets ObjectSearchReady.
func (*Graph) Neighbors ¶
func (g *Graph) Neighbors(ctx context.Context, objectID uuid.UUID, relationTypes []string, limit int) ([]brain.GraphNeighbor, error)
Neighbors walks OutE then InE per label via EdgeProperties (internal $from/$to), then resolves peers to object_id. ProjectFromEndpoint on edges is unsupported on current Helix images.
func (*Graph) ObjectSearchReady ¶
ObjectSearchReady reports whether Bootstrap (or EnsureSearchIndexes) succeeded.
func (*Graph) RemoveEdge ¶ added in v0.2.0
RemoveEdge implements brain.GraphWriter via Helix DropEdgeLabeled.
func (*Graph) RemoveObject ¶
RemoveObject implements brain.GraphWriter: drop graph nodes for this object_id. Helix drops incident edges with the node.
func (*Graph) SearchEdgesText ¶
func (g *Graph) SearchEdgesText(ctx context.Context, relationLabel, query string, limit int) ([]brain.EdgeSearchHit, error)
SearchEdgesText implements brain.GraphEdgeSearcher via Helix TextSearchEdges on note. Requires EnsureEdgeTextIndex(rel) for that label.
Live Helix returns edge props with internal $from/$to node ids (ProjectFromEndpoint on edges is not supported); we resolve those ids to object_id UUIDs.
func (*Graph) SearchText ¶
func (g *Graph) SearchText(ctx context.Context, query string, limit int, namespace brain.Namespace) ([]brain.ScoredID, error)
SearchText implements brain.GraphObjectSearcher via Helix TextSearchNodes. Helix is unscoped; Engine hydrates under Scope (Namespace.Covers).
func (*Graph) SearchVector ¶
func (g *Graph) SearchVector(ctx context.Context, embedding []float32, limit int, namespace brain.Namespace) ([]brain.ScoredID, error)
SearchVector implements brain.GraphObjectSearcher via Helix VectorSearchNodes.
func (*Graph) TenantEnabled ¶
TenantEnabled reports whether search indexes were created with a namespace tenant property.