helixgraph

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

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

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

func NewFromClient(client *helix.Client) (*Graph, error)

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

func (g *Graph) Bootstrap(ctx context.Context, withNamespaceTenant bool) error

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) Client

func (g *Graph) Client() *helix.Client

Client returns the underlying SDK client (e.g. for host-side seeding).

func (*Graph) EnsureEdgeTextIndex

func (g *Graph) EnsureEdgeTextIndex(ctx context.Context, relationLabel string) error

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

func (g *Graph) EnsureObject(ctx context.Context, obj brain.Object) error

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

func (g *Graph) EnsureSearchIndexes(ctx context.Context, withNamespaceTenant bool) error

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

func (g *Graph) ObjectSearchReady() bool

ObjectSearchReady reports whether Bootstrap (or EnsureSearchIndexes) succeeded.

func (*Graph) RemoveEdge added in v0.2.0

func (g *Graph) RemoveEdge(ctx context.Context, from, to uuid.UUID, relationType string) error

RemoveEdge implements brain.GraphWriter via Helix DropEdgeLabeled.

func (*Graph) RemoveObject

func (g *Graph) RemoveObject(ctx context.Context, id uuid.UUID) error

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

func (g *Graph) TenantEnabled() bool

TenantEnabled reports whether search indexes were created with a namespace tenant property.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL