Documentation
¶
Overview ¶
Package helixgraph is a brain.Graph on HelixDB.
Helix does the work natively: filters apply before ranking (*Within searches over the readable candidates that pass them), a neighborhood walk of any depth is one request, and endpoints come back as object ids, not internal node ids. The graph embeds node text, edge notes and queries with its own Embedding and fuses its text and vector lists with its own Ranking. Open creates the indexes and waits until they are active.
Each node and edge stores its tenant key, which partitions the text and vector indexes, and its namespace attrs as one token set. A node also stores its Readers and its scalar properties as token sets. A token is a hash of an attr or a principal, so the graph holds no principal ids, and one property write replaces a whole set. A query reads a node when it covers the node's namespace and the node has no readers or shares a principal with it, as brain.Scope.CanRead decides.
Index ¶
- type Graph
- func (g *Graph) Erase(ctx context.Context, scope brain.Scope) error
- func (g *Graph) FindLinks(ctx context.Context, lq brain.LinkSearch) ([]brain.EdgeSearchHit, error)
- func (g *Graph) FindObjects(ctx context.Context, sq brain.ObjectSearch) ([]brain.ScoredID, error)
- func (g *Graph) Link(ctx context.Context, e brain.GraphEdge) error
- func (g *Graph) Neighborhood(ctx context.Context, nq brain.NeighborhoodQuery) (brain.NeighborPage, error)
- func (g *Graph) Put(ctx context.Context, in brain.Indexed) error
- func (g *Graph) Reach(ctx context.Context, w brain.Walk) (brain.Reached, error)
- func (g *Graph) Remove(ctx context.Context, id uuid.UUID) error
- func (g *Graph) Unlink(ctx context.Context, from, to uuid.UUID, rel string) error
- type Options
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 is a HelixDB knowledge graph.
func Open ¶ added in v0.5.0
Open returns a graph over client after it creates every index opts needs and they are active.
func (*Graph) Erase ¶ added in v0.5.0
Erase implements brain.Index in one write: it drops every node the scope's namespace covers, whatever its readers, and Helix drops their edges.
func (*Graph) FindLinks ¶ added in v0.5.0
func (g *Graph) FindLinks(ctx context.Context, lq brain.LinkSearch) ([]brain.EdgeSearchHit, error)
FindLinks implements brain.Graph in one request, like FindObjects, over the edges of one relation the namespace covers whose two ends the query can read. A tenant-wide scope excludes the edges of the tenant's hidden nodes. Helix rejects a relation not in Options.EdgeRelations.
func (*Graph) FindObjects ¶ added in v0.5.0
FindObjects implements brain.Graph in one request: a text and, with an Embedder, a vector ranking over the readable nodes that pass q.Filters (and are among q.IDs when set), fused with the graph's Ranking. A tenant-wide scope with no filters or ids ranks from the index (see visiblePlan); otherwise Helix ranks within the readable candidates.
func (*Graph) Link ¶ added in v0.5.0
Link implements brain.Graph: one write that drops any edge from→to with the relation and adds the new one, with the note's embedding when the graph has an Embedder.
func (*Graph) Neighborhood ¶ added in v0.5.0
func (g *Graph) Neighborhood(ctx context.Context, nq brain.NeighborhoodQuery) (brain.NeighborPage, error)
Neighborhood implements brain.Graph in one request, or two when it counts every relation: the first finds the relations the walk follows. For each depth from the cursor's, the request returns up to Limit+1 rows in order, and the edges from the depth's frontier into those rows.
func (*Graph) Put ¶ added in v0.5.0
Put implements brain.Graph: one write that updates the node in place when it exists (keeping its edges) and adds it otherwise. It embeds the text first when the graph has an Embedder.
func (*Graph) Reach ¶ added in v0.5.2
Reach implements brain.Graph in one request: every hop keeps its frontier, and the frontiers are the result.
type Options ¶ added in v0.5.0
type Options struct {
// Dimension is the embedding length of nodes and edges. Zero means no
// vector indexes: searches rank text only.
Dimension uint
// Metric is the vector distance (default cosine).
Metric helix.VectorDistanceMetric
// EdgeRelations are the relations whose edges FindLinks can rank; a
// FindLinks without a relation ranks them all.
EdgeRelations []string
// MaxOverfetch is how many elements a tenant-wide search may skip because
// the caller cannot read them, and still rank from the index (default
// 256). Past it, Helix ranks within the readable candidates.
MaxOverfetch uint
// Embedding embeds node text, edge notes and queries. Its vectors must
// have Dimension values. Without an Embedder, searches rank text only.
Embedding brain.Embedding
// Ranking fuses the text and vector lists and ages them by updated_at.
Ranking brain.Ranking
}
Options configures Open.