Documentation
¶
Index ¶
- Constants
- type BatchEdgeOperation
- type BatchGraphOperation
- type BatchNodeOperation
- type BatchResult
- type Community
- type Connectivity
- type EdgeEndpoint
- type EdgeEndpointPair
- type EdgePrediction
- type EdgeShape
- type ExportFormat
- type GEXFAttValue
- type GEXFAttr
- type GEXFAttrs
- type GEXFDocument
- type GEXFEdge
- type GEXFEdges
- type GEXFGraph
- type GEXFMeta
- type GEXFNode
- type GEXFNodes
- type GraphEdge
- type GraphFilter
- type GraphMLData
- type GraphMLDocument
- type GraphMLEdge
- type GraphMLGraph
- type GraphMLKey
- type GraphMLNode
- type GraphNode
- type GraphResult
- type GraphStatistics
- type GraphStore
- func (g *GraphStore) CommunityDetection(ctx context.Context) ([]Community, error)
- func (g *GraphStore) CompactIRI(ctx context.Context, value string) (string, error)
- func (g *GraphStore) Connected(ctx context.Context, nodeID1, nodeID2 string, maxDepth int) (bool, error)
- func (g *GraphStore) Connectivity(ctx context.Context) (Connectivity, error)
- func (g *GraphStore) CountNodes(ctx context.Context, filter *GraphFilter) (int, error)
- func (g *GraphStore) DeleteEdge(ctx context.Context, edgeID string) error
- func (g *GraphStore) DeleteEdgesBatch(ctx context.Context, edgeIDs []string) (*BatchResult, error)
- func (g *GraphStore) DeleteNamespace(ctx context.Context, prefix string) error
- func (g *GraphStore) DeleteNode(ctx context.Context, nodeID string) error
- func (g *GraphStore) DeleteNodesBatch(ctx context.Context, nodeIDs []string) (*BatchResult, error)
- func (g *GraphStore) DeleteTriple(ctx context.Context, triple RDFTriple) error
- func (g *GraphStore) DeleteTriples(ctx context.Context, pattern TriplePattern) (int, error)
- func (g *GraphStore) EdgeEndpointPairs(ctx context.Context, edgeTypes ...string) ([]EdgeEndpointPair, error)
- func (g *GraphStore) EdgeShapes(ctx context.Context, edgeTypes ...string) ([]EdgeShape, error)
- func (g *GraphStore) EdgeTypeCounts(ctx context.Context) (map[string]int, error)
- func (g *GraphStore) EnableHNSWIndex(dimensions int) error
- func (g *GraphStore) ExecuteBatch(ctx context.Context, ops *BatchGraphOperation) (*BatchResult, error)
- func (g *GraphStore) ExecuteBatchTx(ctx context.Context, tx *sql.Tx, ops *BatchGraphOperation) (*BatchResult, error)
- func (g *GraphStore) ExecuteSPARQL(ctx context.Context, query string) (*SPARQLResult, error)
- func (g *GraphStore) ExpandIRI(ctx context.Context, value string) (string, error)
- func (g *GraphStore) ExplainTriple(ctx context.Context, tripleID string) (*RDFSInferenceExplanation, error)
- func (g *GraphStore) ExplainTripleTrace(ctx context.Context, tripleID string, depth int) ([]RDFSInferenceTraceEntry, error)
- func (g *GraphStore) ExplainTriplesByPattern(ctx context.Context, pattern TriplePattern, depth int) ([]RDFSInferenceMatchExplanation, error)
- func (g *GraphStore) Export(ctx context.Context, writer io.Writer, format ExportFormat) error
- func (g *GraphStore) ExportGEXF(ctx context.Context, writer io.Writer) error
- func (g *GraphStore) ExportGraphML(ctx context.Context, writer io.Writer) error
- func (g *GraphStore) ExportJSON(ctx context.Context, writer io.Writer) error
- func (g *GraphStore) ExportRDF(ctx context.Context, writer io.Writer, format RDFFormat) error
- func (g *GraphStore) FindTriples(ctx context.Context, pattern TriplePattern) ([]RDFTriple, error)
- func (g *GraphStore) GetAllNodes(ctx context.Context, filter *GraphFilter) ([]*GraphNode, error)
- func (g *GraphStore) GetEdges(ctx context.Context, nodeID string, direction string) ([]*GraphEdge, error)
- func (g *GraphStore) GetEdgesBatch(ctx context.Context, edgeIDs []string) ([]*GraphEdge, error)
- func (g *GraphStore) GetGraphStatistics(ctx context.Context) (*GraphStatistics, error)
- func (g *GraphStore) GetNode(ctx context.Context, nodeID string) (*GraphNode, error)
- func (g *GraphStore) GetNodesBatch(ctx context.Context, nodeIDs []string) ([]*GraphNode, error)
- func (g *GraphStore) GetTriple(ctx context.Context, id string) (*RDFTriple, error)
- func (g *GraphStore) GraphVectorSearch(ctx context.Context, startNodeID string, vector []float32, ...) ([]*HybridResult, error)
- func (g *GraphStore) HNSWHybridSearch(ctx context.Context, query *HybridQuery) ([]*HybridResult, error)
- func (g *GraphStore) HNSWSearch(ctx context.Context, query []float32, k int, threshold float64) ([]*HybridResult, error)
- func (g *GraphStore) HybridSearch(ctx context.Context, query *HybridQuery) ([]*HybridResult, error)
- func (g *GraphStore) Import(ctx context.Context, reader io.Reader, format ExportFormat) error
- func (g *GraphStore) ImportGEXF(ctx context.Context, reader io.Reader) error
- func (g *GraphStore) ImportGraphML(ctx context.Context, reader io.Reader) error
- func (g *GraphStore) ImportJSON(ctx context.Context, reader io.Reader) error
- func (g *GraphStore) ImportRDF(ctx context.Context, reader io.Reader, format RDFFormat) (int, error)
- func (g *GraphStore) InferenceSummary(ctx context.Context) (*RDFSInferenceSummary, error)
- func (g *GraphStore) InitGraphSchema(ctx context.Context) error
- func (g *GraphStore) ListNamespaces(ctx context.Context) ([]Namespace, error)
- func (g *GraphStore) ListNodes(ctx context.Context, filter *GraphFilter) ([]*GraphNode, error)
- func (g *GraphStore) MergeEntities(ctx context.Context, canonicalID string, aliasIDs []string) error
- func (g *GraphStore) Neighbors(ctx context.Context, nodeID string, opts TraversalOptions) ([]*GraphNode, error)
- func (g *GraphStore) NodeLabels(ctx context.Context, q NodeLabelQuery) ([]NodeLabel, error)
- func (g *GraphStore) NodeTypeCounts(ctx context.Context) (map[string]int, error)
- func (g *GraphStore) PageRank(ctx context.Context, iterations int, dampingFactor float64) ([]PageRankResult, error)
- func (g *GraphStore) PredictEdges(ctx context.Context, nodeID string, topK int) ([]EdgePrediction, error)
- func (g *GraphStore) RefreshRDFSInferences(ctx context.Context) (*RDFSInferenceRefreshResult, error)
- func (g *GraphStore) RefreshRDFSInferencesIncremental(ctx context.Context, changedTriples []RDFTriple) (*RDFSInferenceRefreshResult, error)
- func (g *GraphStore) SPARQLMutates(ctx context.Context, query string) bool
- func (g *GraphStore) ShortestPath(ctx context.Context, fromID, toID string) (*PathResult, error)
- func (g *GraphStore) SimilarityInGraph(ctx context.Context, nodeID string, opts core.SearchOptions) ([]*HybridResult, error)
- func (g *GraphStore) Subgraph(ctx context.Context, nodeIDs []string) (*GraphResult, error)
- func (g *GraphStore) SyncDeletedNodeIDs(_ context.Context, nodeIDs []string)
- func (g *GraphStore) SyncUpsertedNodes(_ context.Context, nodes []*GraphNode)
- func (g *GraphStore) UpsertEdge(ctx context.Context, edge *GraphEdge) error
- func (g *GraphStore) UpsertEdgesBatch(ctx context.Context, edges []*GraphEdge) (*BatchResult, error)
- func (g *GraphStore) UpsertNamespace(ctx context.Context, ns Namespace) error
- func (g *GraphStore) UpsertNode(ctx context.Context, node *GraphNode) error
- func (g *GraphStore) UpsertNodesBatch(ctx context.Context, nodes []*GraphNode) (*BatchResult, error)
- func (g *GraphStore) UpsertTriple(ctx context.Context, triple *RDFTriple) error
- func (g *GraphStore) UpsertTriplesBatch(ctx context.Context, triples []*RDFTriple) (*BatchResult, error)
- func (g *GraphStore) ValidateSHACL(ctx context.Context, shapeTriples []RDFTriple) (*SHACLReport, error)
- type HNSWGraphIndex
- type HybridQuery
- type HybridResult
- type HybridWeights
- type Namespace
- type NodeLabel
- type NodeLabelQuery
- type PageRankResult
- type PathResult
- type RDFFormat
- type RDFSInferenceExplanation
- type RDFSInferenceMatchExplanation
- type RDFSInferenceRefreshResult
- type RDFSInferenceSummary
- type RDFSInferenceTraceEntry
- type RDFTerm
- type RDFTriple
- type SHACLReport
- type SHACLValidationResult
- type SPARQLResult
- type SimpleHNSW
- type TraversalOptions
- type TriplePattern
Constants ¶
const ( // RDFTermIRI represents an IRI/resource term. RDFTermIRI = "iri" // RDFTermBlankNode represents a blank node term. RDFTermBlankNode = "blank_node" // RDFTermLiteral represents a literal term. RDFTermLiteral = "literal" )
const ( SHACLNamespace = "http://www.w3.org/ns/shacl#" RDFNamespace = "http://www.w3.org/1999/02/22-rdf-syntax-ns#" XSDNamespace = "http://www.w3.org/2001/XMLSchema#" SHACLNodeShape = SHACLNamespace + "NodeShape" SHACLPropertyShape = SHACLNamespace + "PropertyShape" SHACLProperty = SHACLNamespace + "property" SHACLPath = SHACLNamespace + "path" SHACLTargetClass = SHACLNamespace + "targetClass" SHACLTargetNode = SHACLNamespace + "targetNode" SHACLDatatype = SHACLNamespace + "datatype" SHACLMinCount = SHACLNamespace + "minCount" SHACLMaxCount = SHACLNamespace + "maxCount" SHACLMinInclusive = SHACLNamespace + "minInclusive" SHACLMaxInclusive = SHACLNamespace + "maxInclusive" SHACLPattern = SHACLNamespace + "pattern" SHACLIn = SHACLNamespace + "in" SHACLNodeKind = SHACLNamespace + "nodeKind" SHACLClass = SHACLNamespace + "class" SHACLSeverity = SHACLNamespace + "severity" SHACLMessage = SHACLNamespace + "message" SHACLSeverityInfo = SHACLNamespace + "Info" SHACLSeverityWarning = SHACLNamespace + "Warning" SHACLSeverityViolation = SHACLNamespace + "Violation" SHACLIRI = SHACLNamespace + "IRI" SHACLBlankNode = SHACLNamespace + "BlankNode" SHACLLiteral = SHACLNamespace + "Literal" SHACLBlankNodeOrIRI = SHACLNamespace + "BlankNodeOrIRI" SHACLBlankNodeOrLiteral = SHACLNamespace + "BlankNodeOrLiteral" SHACLIRIOrLiteral = SHACLNamespace + "IRIOrLiteral" RDFType = RDFNamespace + "type" )
SHACL IRIs
const ( // SPARQLQuerySelect executes a tabular SELECT query. SPARQLQuerySelect = "select" // SPARQLQueryAsk executes a boolean ASK query. SPARQLQueryAsk = "ask" // SPARQLQueryConstruct executes a graph-producing CONSTRUCT query. SPARQLQueryConstruct = "construct" // SPARQLQueryDescribe executes a graph-producing DESCRIBE query. SPARQLQueryDescribe = "describe" // SPARQLQueryInsertData executes an INSERT DATA update. SPARQLQueryInsertData = "insert_data" // SPARQLQueryDeleteData executes a DELETE DATA update. SPARQLQueryDeleteData = "delete_data" // SPARQLQueryDeleteWhere executes a DELETE WHERE update. SPARQLQueryDeleteWhere = "delete_where" // SPARQLQueryModify executes INSERT ... WHERE / DELETE ... INSERT ... WHERE style updates. SPARQLQueryModify = "modify" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchEdgeOperation ¶
type BatchEdgeOperation struct {
Edges []*GraphEdge
}
BatchEdgeOperation represents a batch operation for edges
type BatchGraphOperation ¶
type BatchGraphOperation struct {
NodeUpserts []*GraphNode
NodeDeletes []string
EdgeUpserts []*GraphEdge
EdgeDeletes []string
}
BatchGraphOperation allows multiple graph operations in a single transaction
type BatchNodeOperation ¶
type BatchNodeOperation struct {
Nodes []*GraphNode
}
BatchNodeOperation represents a batch operation for nodes
type BatchResult ¶
BatchResult contains the results of a batch operation.
A batch is partial by design: one rejected row does not roll the others back, so the batch functions report per-row failures here and reserve their error return for failures of the batch itself (transaction, prepare, commit). That makes it easy to lose writes without noticing — a caller that only checks err sees success for a batch in which every row was rejected. Call Err to fold the per-row failures back into a normal error before reporting success upwards.
func (*BatchResult) Err ¶ added in v2.69.0
func (r *BatchResult) Err() error
Err returns the per-row failures of a batch joined into a single error, or nil when every row the caller supplied was written.
Only rows that actually failed are reported: the delete batches count ids that matched nothing as failed without recording an error, because "not there" is not a failure to delete. The upsert batches record an error for every failure they count.
type Community ¶
type Community struct {
ID int `json:"id"`
Nodes []string `json:"nodes"`
Score float64 `json:"score"` // Modularity score
}
Community represents a detected community of nodes
type Connectivity ¶ added in v2.86.0
Connectivity is how much of the graph an edge can reach.
type EdgeEndpoint ¶ added in v2.85.0
type EdgeEndpoint struct {
ID string `json:"id"`
NodeType string `json:"node_type"`
Content string `json:"content"`
}
EdgeEndpoint identifies one end of an edge, with enough about the node to name it in a report without a second round trip.
type EdgeEndpointPair ¶ added in v2.85.0
type EdgeEndpointPair struct {
EdgeType string `json:"edge_type"`
From EdgeEndpoint `json:"from"`
To EdgeEndpoint `json:"to"`
Count int `json:"count"`
}
EdgeEndpointPair is one (edge type, from node, to node) combination and how many edges join exactly those two nodes with that type.
type EdgePrediction ¶
type EdgePrediction struct {
FromNodeID string `json:"from_node_id"`
ToNodeID string `json:"to_node_id"`
Score float64 `json:"score"`
Method string `json:"method"`
}
EdgePrediction represents a predicted edge with confidence score
type EdgeShape ¶ added in v2.85.0
type EdgeShape struct {
EdgeType string `json:"edge_type"`
FromType string `json:"from_type"`
ToType string `json:"to_type"`
Count int `json:"count"`
}
EdgeShape is one (edge type, from-node type, to-node type) combination present in the graph, and how many edges have it.
type ExportFormat ¶
type ExportFormat string
ExportFormat represents supported export formats
const ( FormatGraphML ExportFormat = "graphml" FormatGEXF ExportFormat = "gexf" FormatJSON ExportFormat = "json" )
func DetectFormat ¶
func DetectFormat(reader io.Reader) (ExportFormat, error)
DetectFormat attempts to detect the format of the input
type GEXFAttValue ¶
GEXFAttValue represents a GEXF attribute value
type GEXFAttr ¶
type GEXFAttr struct {
ID string `xml:"id,attr"`
Title string `xml:"title,attr"`
Type string `xml:"type,attr"`
}
GEXFAttr represents a GEXF attribute
type GEXFDocument ¶
type GEXFDocument struct {
XMLName xml.Name `xml:"gexf"`
XMLNS string `xml:"xmlns,attr"`
Version string `xml:"version,attr"`
Meta GEXFMeta `xml:"meta"`
Graph GEXFGraph `xml:"graph"`
}
GEXFDocument represents a GEXF document
type GEXFEdge ¶
type GEXFEdge struct {
ID string `xml:"id,attr"`
Source string `xml:"source,attr"`
Target string `xml:"target,attr"`
Weight float64 `xml:"weight,attr,omitempty"`
Type string `xml:"type,attr,omitempty"`
}
GEXFEdge represents a GEXF edge
type GEXFEdges ¶
type GEXFEdges struct {
Edges []GEXFEdge `xml:"edge"`
}
GEXFEdges represents GEXF edges container
type GEXFGraph ¶
type GEXFGraph struct {
Mode string `xml:"mode,attr"`
DefaultEdgeType string `xml:"defaultedgetype,attr"`
Attributes GEXFAttrs `xml:"attributes"`
Nodes GEXFNodes `xml:"nodes"`
Edges GEXFEdges `xml:"edges"`
}
GEXFGraph represents a GEXF graph
type GEXFNode ¶
type GEXFNode struct {
ID string `xml:"id,attr"`
Label string `xml:"label,attr"`
AttValues []GEXFAttValue `xml:"attvalues>attvalue"`
}
GEXFNode represents a GEXF node
type GEXFNodes ¶
type GEXFNodes struct {
Nodes []GEXFNode `xml:"node"`
}
GEXFNodes represents GEXF nodes container
type GraphEdge ¶
type GraphEdge struct {
ID string `json:"id"`
FromNodeID string `json:"from_node_id"`
ToNodeID string `json:"to_node_id"`
EdgeType string `json:"edge_type,omitempty"`
Weight float64 `json:"weight"`
Properties map[string]interface{} `json:"properties,omitempty"`
Vector []float32 `json:"vector,omitempty"` // Optional edge embedding
CreatedAt time.Time `json:"created_at"`
}
GraphEdge represents a directed edge between two nodes
type GraphFilter ¶
type GraphFilter struct {
NodeTypes []string `json:"node_types,omitempty"`
EdgeTypes []string `json:"edge_types,omitempty"`
MaxDepth int `json:"max_depth,omitempty"`
// Properties scopes a query to nodes whose properties JSON carries every
// one of these top-level string fields with these values.
//
// It exists because a store this one shares with everything else on the
// machine had no way to ask for one importer's rows. node_type was the
// only filter, and a type name is not a batch: an importer that wrote a
// thousand Person nodes on Tuesday and a thousand more on Friday could
// not ask for either set, only for all two thousand. Every writer that
// cared already stamped a batch onto properties — alchemy's connector
// writes "run" — and nothing could read it back.
//
// The fields are ANDed, and each is compared as text: properties is a
// JSON object serialized by json.Marshal, and the guarded read in
// pkg/sqldialect is what keeps a row with no properties at all from
// failing the whole query rather than simply not matching.
Properties map[string]string `json:"properties,omitempty"`
// Contains narrows to nodes whose property holds this text somewhere in
// it, compared case-insensitively and ANDed with everything else.
//
// Separate from Properties because the two are different questions and
// only one of them can use an index: Properties is how a caller names a
// batch it already knows, Contains is how a search enters the graph at
// all. Folding them into one map would make every batch scope a LIKE.
//
// The value is matched literally — % and _ in it mean those characters,
// not wildcards — because the text comes from whoever typed the query and
// a name with an underscore in it is ordinary.
Contains map[string]string `json:"contains,omitempty"`
// Limit caps the rows a query returns. Zero means no cap, which is what
// every caller before this field got and still gets.
//
// A cap alone would be worse than none: a caller shown 100 of 4000 rows
// with nothing saying so reports 100. CountNodes answers the other half,
// and the two are meant to be used together.
Limit int `json:"limit,omitempty"`
}
GraphFilter defines filtering options for graph queries
type GraphMLData ¶
GraphMLData represents GraphML data
type GraphMLDocument ¶
type GraphMLDocument struct {
XMLName xml.Name `xml:"graphml"`
XMLNS string `xml:"xmlns,attr"`
Keys []GraphMLKey `xml:"key"`
Graph GraphMLGraph `xml:"graph"`
}
GraphMLDocument represents a GraphML document
type GraphMLEdge ¶
type GraphMLEdge struct {
ID string `xml:"id,attr"`
Source string `xml:"source,attr"`
Target string `xml:"target,attr"`
Data []GraphMLData `xml:"data"`
}
GraphMLEdge represents a GraphML edge
type GraphMLGraph ¶
type GraphMLGraph struct {
ID string `xml:"id,attr"`
EdgeDefault string `xml:"edgedefault,attr"`
Nodes []GraphMLNode `xml:"node"`
Edges []GraphMLEdge `xml:"edge"`
}
GraphMLGraph represents a GraphML graph
type GraphMLKey ¶
type GraphMLKey struct {
ID string `xml:"id,attr"`
For string `xml:"for,attr"`
AttrName string `xml:"attr.name,attr"`
AttrType string `xml:"attr.type,attr"`
}
GraphMLKey represents a GraphML key definition
type GraphMLNode ¶
type GraphMLNode struct {
ID string `xml:"id,attr"`
Data []GraphMLData `xml:"data"`
}
GraphMLNode represents a GraphML node
type GraphNode ¶
type GraphNode struct {
ID string `json:"id"`
Vector []float32 `json:"vector"`
Content string `json:"content,omitempty"`
NodeType string `json:"node_type,omitempty"`
Properties map[string]interface{} `json:"properties,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
GraphNode represents a node in the graph with vector embedding
type GraphResult ¶
GraphResult represents a subgraph or query result
type GraphStatistics ¶
type GraphStatistics struct {
NodeCount int `json:"node_count"`
EdgeCount int `json:"edge_count"`
AverageDegree float64 `json:"average_degree"`
Density float64 `json:"density"`
ConnectedComponents int `json:"connected_components"`
}
GraphStatistics represents overall graph statistics
type GraphStore ¶
type GraphStore struct {
// contains filtered or unexported fields
}
GraphStore provides graph operations on top of the vector store
func NewGraphStore ¶
func NewGraphStore(s *core.SQLiteStore) *GraphStore
NewGraphStore creates a new graph store from a SQLite store.
func NewGraphStoreOn ¶ added in v2.82.0
func NewGraphStoreOn(db *sql.DB, d sqldialect.Dialect, host vectorHost) *GraphStore
NewGraphStoreOn creates a graph store over any database this dialect can speak, for a host that supplies the vector-side settings.
The same tables and the same queries as NewGraphStore — the graph layer has no SQLite-only SQL in it, which is what makes one implementation over two databases possible rather than two implementations to keep in step.
func (*GraphStore) CommunityDetection ¶
func (g *GraphStore) CommunityDetection(ctx context.Context) ([]Community, error)
CommunityDetection performs community detection using the Louvain method Optimized to reduce DB queries.
func (*GraphStore) CompactIRI ¶ added in v2.16.0
CompactIRI compacts an IRI using the longest matching namespace prefix when available.
func (*GraphStore) Connected ¶
func (g *GraphStore) Connected(ctx context.Context, nodeID1, nodeID2 string, maxDepth int) (bool, error)
Connected checks if two nodes are connected within a given depth
func (*GraphStore) Connectivity ¶ added in v2.86.0
func (g *GraphStore) Connectivity(ctx context.Context) (Connectivity, error)
Connectivity counts the nodes no edge touches, alongside the total.
A large share of orphans means writes landed and their edges did not — the state a store reaches when an ingest's edges are rejected, or when entities accumulate across re-ingests with nothing joining them. Retrieval still finds these nodes and expansion never leaves them, so the graph half of GraphRAG quietly stops contributing while every count still grows.
Both numbers come from one statement so they describe one graph. Asked separately, a write between them yields a share that was never true — and this is a health check, whose whole output is that ratio.
Distinct from GraphStatistics.ConnectedComponents, which asks how the reachable part is divided; this asks how much of the graph is reachable at all.
func (*GraphStore) CountNodes ¶ added in v2.89.0
func (g *GraphStore) CountNodes(ctx context.Context, filter *GraphFilter) (int, error)
CountNodes reports how many nodes match a filter, ignoring its Limit.
It is the other half of GraphFilter.Limit and it is not optional decoration. A caller that asks for 100 nodes and is handed 100 has learned nothing about whether there were 100 or 4000, and the honest failure — "showing 100 of 4000" — is unavailable without this. Callers that report a total to a person or to a model should ask for both.
Limit is ignored on purpose: a count that stopped at the cap would always equal the cap, which is the exact non-answer this method exists to replace.
func (*GraphStore) DeleteEdge ¶
func (g *GraphStore) DeleteEdge(ctx context.Context, edgeID string) error
DeleteEdge removes an edge from the graph
func (*GraphStore) DeleteEdgesBatch ¶
func (g *GraphStore) DeleteEdgesBatch(ctx context.Context, edgeIDs []string) (*BatchResult, error)
DeleteEdgesBatch deletes multiple edges in a single transaction
func (*GraphStore) DeleteNamespace ¶ added in v2.16.0
func (g *GraphStore) DeleteNamespace(ctx context.Context, prefix string) error
DeleteNamespace removes one user-defined namespace mapping.
func (*GraphStore) DeleteNode ¶
func (g *GraphStore) DeleteNode(ctx context.Context, nodeID string) error
DeleteNode removes a node and all its edges
func (*GraphStore) DeleteNodesBatch ¶
func (g *GraphStore) DeleteNodesBatch(ctx context.Context, nodeIDs []string) (*BatchResult, error)
DeleteNodesBatch deletes multiple nodes in a single transaction
func (*GraphStore) DeleteTriple ¶ added in v2.16.0
func (g *GraphStore) DeleteTriple(ctx context.Context, triple RDFTriple) error
DeleteTriple removes one RDF triple/quad by its normalized content.
func (*GraphStore) DeleteTriples ¶ added in v2.16.0
func (g *GraphStore) DeleteTriples(ctx context.Context, pattern TriplePattern) (int, error)
DeleteTriples removes all triples matched by the given pattern.
func (*GraphStore) EdgeEndpointPairs ¶ added in v2.85.0
func (g *GraphStore) EdgeEndpointPairs(ctx context.Context, edgeTypes ...string) ([]EdgeEndpointPair, error)
EdgeEndpointPairs reports which nodes the edges of each type actually run between.
EdgeShapes groups by type, which answers "how is this relation wrong" and not "what is wrong". On a live base eighteen non-conforming edges came from thirteen nodes, two of which carried six between them — six edges, two places to look. Getting from one answer to the other needs the nodes, and getting the nodes needs their identity, which is why this returns content and type alongside the id rather than a list of ids to look up afterwards.
Ordering, filtering, and the treatment of missing endpoints are the same as EdgeShapes. This scans one row per distinct (type, from, to) triple, so on a large graph pass the edge types the caller actually cares about.
func (*GraphStore) EdgeShapes ¶ added in v2.85.0
EdgeShapes reports the type shapes the graph's edges actually have.
This is what makes a declared relation checkable. An extracted `backs` asserted from the resource to the pool is stored without complaint, reads as a fact, and is walked as one; nothing in the answer it produces says the arrow points the wrong way. Comparing these shapes against the declared ends is the only thing that can disagree with it.
Passing edge types narrows the scan to those; passing none reports every shape in the graph. They are matched exactly, as stored — the same rule the traversal filters use, since the type in the graph is whatever the extracting model emitted and this package nowhere decides what a near-miss means.
Edges whose endpoints are missing are not reported: both endpoints are declared foreign keys, so on a store this package opened they cannot exist.
func (*GraphStore) EdgeTypeCounts ¶ added in v2.85.0
EdgeTypeCounts returns how many edges carry each edge_type, with untyped edges under the empty string for the same reason as NodeTypeCounts.
func (*GraphStore) EnableHNSWIndex ¶
func (g *GraphStore) EnableHNSWIndex(dimensions int) error
EnableHNSWIndex enables HNSW indexing for the graph store
func (*GraphStore) ExecuteBatch ¶
func (g *GraphStore) ExecuteBatch(ctx context.Context, ops *BatchGraphOperation) (*BatchResult, error)
ExecuteBatch executes multiple graph operations in a single transaction
func (*GraphStore) ExecuteBatchTx ¶ added in v2.14.1
func (g *GraphStore) ExecuteBatchTx(ctx context.Context, tx *sql.Tx, ops *BatchGraphOperation) (*BatchResult, error)
ExecuteBatchTx applies a batch of graph operations inside an existing transaction.
func (*GraphStore) ExecuteSPARQL ¶ added in v2.16.0
func (g *GraphStore) ExecuteSPARQL(ctx context.Context, query string) (*SPARQLResult, error)
ExecuteSPARQL runs a practical SPARQL SELECT/ASK subset against the embedded RDF layer.
func (*GraphStore) ExpandIRI ¶ added in v2.16.0
ExpandIRI expands a compact IRI using registered namespaces when possible.
func (*GraphStore) ExplainTriple ¶ added in v2.16.0
func (g *GraphStore) ExplainTriple(ctx context.Context, tripleID string) (*RDFSInferenceExplanation, error)
ExplainTriple returns whether a triple is explicit or inferred and its immediate provenance.
func (*GraphStore) ExplainTripleTrace ¶ added in v2.16.0
func (g *GraphStore) ExplainTripleTrace(ctx context.Context, tripleID string, depth int) ([]RDFSInferenceTraceEntry, error)
ExplainTripleTrace recursively expands provenance for a triple into a flattened trace list.
func (*GraphStore) ExplainTriplesByPattern ¶ added in v2.18.0
func (g *GraphStore) ExplainTriplesByPattern(ctx context.Context, pattern TriplePattern, depth int) ([]RDFSInferenceMatchExplanation, error)
ExplainTriplesByPattern expands explanations for all triples matched by the given pattern.
func (*GraphStore) Export ¶
func (g *GraphStore) Export(ctx context.Context, writer io.Writer, format ExportFormat) error
Export exports the graph in the specified format
func (*GraphStore) ExportGEXF ¶
ExportGEXF exports the graph to GEXF format
func (*GraphStore) ExportGraphML ¶
ExportGraphML exports the graph to GraphML format
func (*GraphStore) ExportJSON ¶
ExportJSON exports the graph to JSON format
func (*GraphStore) ExportRDF ¶ added in v2.16.0
ExportRDF writes triples in the requested RDF format.
func (*GraphStore) FindTriples ¶ added in v2.16.0
func (g *GraphStore) FindTriples(ctx context.Context, pattern TriplePattern) ([]RDFTriple, error)
FindTriples queries triples by pattern.
func (*GraphStore) GetAllNodes ¶
func (g *GraphStore) GetAllNodes(ctx context.Context, filter *GraphFilter) ([]*GraphNode, error)
GetAllNodes retrieves all nodes with optional filtering
func (*GraphStore) GetEdges ¶
func (g *GraphStore) GetEdges(ctx context.Context, nodeID string, direction string) ([]*GraphEdge, error)
GetEdges retrieves edges for a node.
Ordered by id, which matters more than it looks: this feeds Neighbors, and Neighbors feeds graph-mode retrieval. Without an ORDER BY, SQLite happens to return insertion order while PostgreSQL returns whatever the plan produced — so the same question could retrieve a different set of chunks on the two backends, and a different set on PostgreSQL from one run to the next once the table had been updated.
func (*GraphStore) GetEdgesBatch ¶
GetEdgesBatch retrieves multiple edges by their IDs
func (*GraphStore) GetGraphStatistics ¶
func (g *GraphStore) GetGraphStatistics(ctx context.Context) (*GraphStatistics, error)
GetGraphStatistics computes statistics about the graph
func (*GraphStore) GetNodesBatch ¶
GetNodesBatch retrieves multiple nodes by their IDs
func (*GraphStore) GraphVectorSearch ¶
func (g *GraphStore) GraphVectorSearch(ctx context.Context, startNodeID string, vector []float32, opts TraversalOptions) ([]*HybridResult, error)
GraphVectorSearch performs vector search within a graph neighborhood
func (*GraphStore) HNSWHybridSearch ¶
func (g *GraphStore) HNSWHybridSearch(ctx context.Context, query *HybridQuery) ([]*HybridResult, error)
HNSWHybridSearch combines HNSW search with graph proximity
func (*GraphStore) HNSWSearch ¶
func (g *GraphStore) HNSWSearch(ctx context.Context, query []float32, k int, threshold float64) ([]*HybridResult, error)
HNSWSearch performs HNSW-accelerated vector search
func (*GraphStore) HybridSearch ¶
func (g *GraphStore) HybridSearch(ctx context.Context, query *HybridQuery) ([]*HybridResult, error)
HybridSearch performs a combined vector and graph search
func (*GraphStore) Import ¶
func (g *GraphStore) Import(ctx context.Context, reader io.Reader, format ExportFormat) error
Import imports a graph in the specified format
func (*GraphStore) ImportGEXF ¶
ImportGEXF imports a graph from GEXF format
func (*GraphStore) ImportGraphML ¶
ImportGraphML imports a graph from GraphML format
func (*GraphStore) ImportJSON ¶
ImportJSON imports a graph from JSON format
func (*GraphStore) ImportRDF ¶ added in v2.16.0
func (g *GraphStore) ImportRDF(ctx context.Context, reader io.Reader, format RDFFormat) (int, error)
ImportRDF parses and stores triples from supported RDF serializations.
func (*GraphStore) InferenceSummary ¶ added in v2.18.0
func (g *GraphStore) InferenceSummary(ctx context.Context) (*RDFSInferenceSummary, error)
InferenceSummary returns explicit/inferred counts and an inference-rule breakdown.
func (*GraphStore) InitGraphSchema ¶
func (g *GraphStore) InitGraphSchema(ctx context.Context) error
InitGraphSchema creates the graph tables if they don't exist.
It is cheap to call repeatedly: after the first success this store remembers that its schema is ready and returns without touching SQLite, so write paths can guard themselves with it instead of trusting the caller to have done so.
func (*GraphStore) ListNamespaces ¶ added in v2.16.0
func (g *GraphStore) ListNamespaces(ctx context.Context) ([]Namespace, error)
ListNamespaces returns built-in and user-defined namespaces.
func (*GraphStore) ListNodes ¶ added in v2.90.0
func (g *GraphStore) ListNodes(ctx context.Context, filter *GraphFilter) ([]*GraphNode, error)
ListNodes is GetAllNodes without the vectors.
The projection is the whole of it, and it is not a micro-optimisation. A vector is the largest column on a node — 768 floats is three kilobytes — and GetAllNodes selects it, decodes it, and hands it to a caller that mostly wants to know what things are called. Enumerating the types in a four-hundred-thousand-node import through GetAllNodes moves a gigabyte of embeddings across the driver and decodes every one of them to count names.
It shares nodeWhere with GetAllNodes and CountNodes, so all three are always about the same rows: a list, a count and a filtered read that disagreed about what matched would be worse than any one of them alone.
Nodes come back with a nil Vector. That is the honest shape — a zero-length vector read from a store that holds one would be a lie about the record, and a caller who needs it has GetAllNodes or GetNode.
func (*GraphStore) MergeEntities ¶ added in v2.26.0
func (g *GraphStore) MergeEntities(ctx context.Context, canonicalID string, aliasIDs []string) error
MergeEntities collapses surface-form duplicate nodes into one canonical node: every edge referencing an alias is repointed to canonicalID, self-loops created by the merge are dropped, and the alias nodes are deleted. Used for entity resolution (e.g. unifying "r0" / "DRBD resource" / "resources" into one entity).
func (*GraphStore) Neighbors ¶
func (g *GraphStore) Neighbors(ctx context.Context, nodeID string, opts TraversalOptions) ([]*GraphNode, error)
Neighbors performs a breadth-first search to find neighboring nodes
func (*GraphStore) NodeLabels ¶ added in v2.86.0
func (g *GraphStore) NodeLabels(ctx context.Context, q NodeLabelQuery) ([]NodeLabel, error)
NodeLabels lists nodes with their type and label.
The question behind it is "what is in here, called what" — which spellings a vocabulary actually produced, whether one concept arrived under two names, which labels are long enough to match text against. Callers were reading graph_nodes for it directly, and pairing a schema they are not promised with an id convention they are not promised either.
Ordered by id so two runs over one graph agree, and so a caller paging with Limit sees a stable sequence rather than whichever rows the planner returned first.
func (*GraphStore) NodeTypeCounts ¶ added in v2.85.0
NodeTypeCounts returns how many nodes carry each node_type.
Untyped nodes are counted under the empty string rather than dropped. A caller that sums these and compares against GetGraphStatistics should get the same number, and "there are 400 nodes nobody typed" is a finding in its own right — silently omitting them turns it into a discrepancy the caller has to explain.
func (*GraphStore) PageRank ¶
func (g *GraphStore) PageRank(ctx context.Context, iterations int, dampingFactor float64) ([]PageRankResult, error)
PageRank calculates PageRank scores for all nodes in the graph Optimized to load only topology (IDs and Edges) instead of full node objects.
func (*GraphStore) PredictEdges ¶
func (g *GraphStore) PredictEdges(ctx context.Context, nodeID string, topK int) ([]EdgePrediction, error)
PredictEdges predicts potential edges using various methods
func (*GraphStore) RefreshRDFSInferences ¶ added in v2.16.0
func (g *GraphStore) RefreshRDFSInferences(ctx context.Context) (*RDFSInferenceRefreshResult, error)
RefreshRDFSInferences recomputes and persists inferred triples using an RDFS-lite ruleset.
func (*GraphStore) RefreshRDFSInferencesIncremental ¶ added in v2.18.0
func (g *GraphStore) RefreshRDFSInferencesIncremental(ctx context.Context, changedTriples []RDFTriple) (*RDFSInferenceRefreshResult, error)
RefreshRDFSInferencesIncremental recomputes inferred triples only for the neighborhood affected by the supplied changed explicit triples.
func (*GraphStore) SPARQLMutates ¶ added in v2.91.0
func (g *GraphStore) SPARQLMutates(ctx context.Context, query string) bool
SPARQLMutates reports whether a query would change the graph.
It exists so authorization can tell a SPARQL read from a SPARQL write, and it is deliberately a thin wrapper over the executor's own parser rather than a second one. The alternative — a policy that recognises "INSERT" and "DELETE" by itself — has to agree with ExecuteSPARQL forever, and the failure when it stops agreeing is silent in the dangerous direction: an update the policy read as a query.
Without this the only safe classification is "every SPARQL call is a write", which costs a read-only key the whole query language, SELECT included.
A query that does not parse is reported as mutating. It is about to fail anyway, and the caller learns nothing from which error it gets.
func (*GraphStore) ShortestPath ¶
func (g *GraphStore) ShortestPath(ctx context.Context, fromID, toID string) (*PathResult, error)
ShortestPath finds the shortest path between two nodes using BFS
func (*GraphStore) SimilarityInGraph ¶
func (g *GraphStore) SimilarityInGraph(ctx context.Context, nodeID string, opts core.SearchOptions) ([]*HybridResult, error)
SimilarityInGraph finds nodes similar to a given node within the graph
func (*GraphStore) Subgraph ¶
func (g *GraphStore) Subgraph(ctx context.Context, nodeIDs []string) (*GraphResult, error)
Subgraph extracts a subgraph containing specified nodes and their connections
func (*GraphStore) SyncDeletedNodeIDs ¶ added in v2.14.1
func (g *GraphStore) SyncDeletedNodeIDs(_ context.Context, nodeIDs []string)
SyncDeletedNodeIDs removes committed graph-node deletions from the optional HNSW index.
func (*GraphStore) SyncUpsertedNodes ¶ added in v2.14.1
func (g *GraphStore) SyncUpsertedNodes(_ context.Context, nodes []*GraphNode)
SyncUpsertedNodes updates the optional graph HNSW index after nodes were committed through ExecuteBatchTx.
func (*GraphStore) UpsertEdge ¶
func (g *GraphStore) UpsertEdge(ctx context.Context, edge *GraphEdge) error
UpsertEdge inserts or updates an edge in the graph
func (*GraphStore) UpsertEdgesBatch ¶
func (g *GraphStore) UpsertEdgesBatch(ctx context.Context, edges []*GraphEdge) (*BatchResult, error)
UpsertEdgesBatch inserts or updates multiple edges in a single transaction
func (*GraphStore) UpsertNamespace ¶ added in v2.16.0
func (g *GraphStore) UpsertNamespace(ctx context.Context, ns Namespace) error
UpsertNamespace stores or replaces one namespace mapping.
func (*GraphStore) UpsertNode ¶
func (g *GraphStore) UpsertNode(ctx context.Context, node *GraphNode) error
UpsertNode inserts or updates a node in the graph
func (*GraphStore) UpsertNodesBatch ¶
func (g *GraphStore) UpsertNodesBatch(ctx context.Context, nodes []*GraphNode) (*BatchResult, error)
UpsertNodesBatch inserts or updates multiple nodes in a single transaction
func (*GraphStore) UpsertTriple ¶ added in v2.16.0
func (g *GraphStore) UpsertTriple(ctx context.Context, triple *RDFTriple) error
UpsertTriple writes one RDF triple/quad and mirrors it into the property graph tables.
func (*GraphStore) UpsertTriplesBatch ¶ added in v2.16.0
func (g *GraphStore) UpsertTriplesBatch(ctx context.Context, triples []*RDFTriple) (*BatchResult, error)
UpsertTriplesBatch writes multiple RDF triples/quads.
func (*GraphStore) ValidateSHACL ¶ added in v2.18.0
func (g *GraphStore) ValidateSHACL(ctx context.Context, shapeTriples []RDFTriple) (*SHACLReport, error)
ValidateSHACL runs SHACL validation against the graph store using the provided shapes.
type HNSWGraphIndex ¶
type HNSWGraphIndex struct {
// contains filtered or unexported fields
}
HNSWGraphIndex provides HNSW-accelerated graph searches
type HybridQuery ¶
type HybridQuery struct {
Vector []float32 `json:"vector,omitempty"`
StartNodeID string `json:"start_node_id,omitempty"`
CenterNodes []string `json:"center_nodes,omitempty"`
GraphFilter *GraphFilter `json:"graph_filter,omitempty"`
TopK int `json:"top_k"`
Threshold float64 `json:"threshold,omitempty"`
VectorThreshold float64 `json:"vector_threshold,omitempty"`
TotalThreshold float64 `json:"total_threshold,omitempty"`
VectorWeight float64 `json:"vector_weight"`
GraphWeight float64 `json:"graph_weight"`
Weights HybridWeights `json:"weights"`
}
HybridQuery represents a combined vector and graph query
type HybridResult ¶
type HybridResult struct {
Node *GraphNode `json:"node"`
VectorScore float64 `json:"vector_score"`
GraphScore float64 `json:"graph_score"`
CombinedScore float64 `json:"combined_score"`
TotalScore float64 `json:"total_score"`
Path []string `json:"path,omitempty"` // Path from start node
Distance int `json:"distance"` // Graph distance from start
}
HybridResult represents a result from hybrid search
type HybridWeights ¶
type HybridWeights struct {
VectorWeight float64 `json:"vector_weight"` // Weight for vector similarity
GraphWeight float64 `json:"graph_weight"` // Weight for graph proximity
EdgeWeight float64 `json:"edge_weight"` // Weight for edge strength
}
HybridWeights defines the weights for hybrid scoring
type NodeLabel ¶ added in v2.86.0
type NodeLabel struct {
ID string `json:"id"`
NodeType string `json:"node_type"`
Content string `json:"content"`
}
NodeLabel is a node's identity together with what it is called.
type NodeLabelQuery ¶ added in v2.86.0
type NodeLabelQuery struct {
// IDPrefix keeps only nodes whose id starts with it. Node ids are
// namespaced by what wrote them, so this is how a caller asks for one
// writer's nodes without knowing how to recognise them from content.
// Matched literally: % and _ in the prefix are not wildcards.
IDPrefix string
// MinContentLength drops nodes whose label is shorter than this, counted
// in characters. 1 excludes the unlabelled.
MinContentLength int
// Limit caps the rows returned. 0 means no cap.
Limit int
}
NodeLabelQuery narrows NodeLabels. A zero query returns every node.
type PageRankResult ¶
PageRankResult represents the PageRank score for a node
type PathResult ¶
type PathResult struct {
Nodes []*GraphNode `json:"nodes"`
Edges []*GraphEdge `json:"edges"`
Distance int `json:"distance"`
Weight float64 `json:"weight"`
}
PathResult represents a path in the graph
type RDFFormat ¶ added in v2.16.0
type RDFFormat string
RDFFormat represents a supported RDF serialization format.
const ( // RDFFormatNTriples exports triples in N-Triples syntax. RDFFormatNTriples RDFFormat = "ntriples" // RDFFormatNQuads exports statements in N-Quads syntax when graph names are present. RDFFormatNQuads RDFFormat = "nquads" // RDFFormatTurtle exports statements in a Turtle-like syntax with prefixes when possible. RDFFormatTurtle RDFFormat = "turtle" // RDFFormatTriG exports quads in TriG syntax with graph blocks. RDFFormatTriG RDFFormat = "trig" )
type RDFSInferenceExplanation ¶ added in v2.16.0
type RDFSInferenceExplanation struct {
Triple RDFTriple `json:"triple"`
Explicit bool `json:"explicit"`
Rule string `json:"rule,omitempty"`
SupportTripleIDs []string `json:"support_triple_ids,omitempty"`
}
RDFSInferenceExplanation returns provenance information for one triple.
type RDFSInferenceMatchExplanation ¶ added in v2.18.0
type RDFSInferenceMatchExplanation struct {
Explanation RDFSInferenceExplanation `json:"explanation"`
Trace []RDFSInferenceTraceEntry `json:"trace,omitempty"`
}
RDFSInferenceMatchExplanation combines explanation and optional trace for one matched triple.
type RDFSInferenceRefreshResult ¶ added in v2.16.0
type RDFSInferenceRefreshResult struct {
ExplicitCount int `json:"explicit_count"`
InferredCount int `json:"inferred_count"`
Incremental bool `json:"incremental,omitempty"`
AffectedExplicitCount int `json:"affected_explicit_count,omitempty"`
RemovedInferredCount int `json:"removed_inferred_count,omitempty"`
}
RDFSInferenceRefreshResult summarizes a refresh of inferred triples.
type RDFSInferenceSummary ¶ added in v2.18.0
type RDFSInferenceSummary struct {
ExplicitCount int `json:"explicit_count"`
InferredCount int `json:"inferred_count"`
Rules map[string]int `json:"rules,omitempty"`
}
RDFSInferenceSummary provides persisted inference counts and rule breakdowns.
type RDFSInferenceTraceEntry ¶ added in v2.16.0
type RDFSInferenceTraceEntry struct {
TripleID string `json:"triple_id"`
ParentTripleID string `json:"parent_triple_id,omitempty"`
Depth int `json:"depth"`
Explanation RDFSInferenceExplanation `json:"explanation"`
Truncated bool `json:"truncated,omitempty"`
}
RDFSInferenceTraceEntry is one flattened node in an explanation trace.
type RDFTerm ¶ added in v2.16.0
type RDFTerm struct {
Kind string `json:"kind"`
Value string `json:"value"`
Datatype string `json:"datatype,omitempty"`
Language string `json:"language,omitempty"`
}
RDFTerm represents one RDF term.
func NewBlankNode ¶ added in v2.16.0
NewBlankNode creates a blank node term.
func NewLangLiteral ¶ added in v2.16.0
NewLangLiteral creates a language-tagged literal term.
func NewLiteral ¶ added in v2.16.0
NewLiteral creates a plain literal term.
func NewTypedLiteral ¶ added in v2.16.0
NewTypedLiteral creates a typed literal term.
type RDFTriple ¶ added in v2.16.0
type RDFTriple struct {
ID string `json:"id,omitempty"`
Subject RDFTerm `json:"subject"`
Predicate RDFTerm `json:"predicate"`
Object RDFTerm `json:"object"`
Graph *RDFTerm `json:"graph,omitempty"`
Inferred bool `json:"inferred,omitempty"`
Rule string `json:"rule,omitempty"`
SupportIDs []string `json:"support_ids,omitempty"`
}
RDFTriple represents one RDF triple or quad when Graph is set.
type SHACLReport ¶ added in v2.18.0
type SHACLReport struct {
Conforms bool `json:"conforms"`
Results []SHACLValidationResult `json:"results,omitempty"`
}
SHACLReport contains the outcome of SHACL validation.
type SHACLValidationResult ¶ added in v2.18.0
type SHACLValidationResult struct {
FocusNode RDFTerm `json:"focus_node"`
Path RDFTerm `json:"path"`
Value RDFTerm `json:"value,omitempty"`
Message string `json:"message"`
Severity string `json:"severity"`
Source RDFTerm `json:"source_shape"`
}
SHACLValidationResult represents a single constraint violation.
type SPARQLResult ¶ added in v2.16.0
type SPARQLResult struct {
QueryType string `json:"query_type"`
Vars []string `json:"vars,omitempty"`
Bindings []map[string]RDFTerm `json:"bindings,omitempty"`
Triples []RDFTriple `json:"triples,omitempty"`
Boolean bool `json:"boolean,omitempty"`
Count int `json:"count"`
}
SPARQLResult contains the result of executing a SPARQL query.
type SimpleHNSW ¶
type SimpleHNSW struct {
// contains filtered or unexported fields
}
SimpleHNSW implements a simplified HNSW-like index for vector search
func NewSimpleHNSW ¶
func NewSimpleHNSW(dimensions int, maxConns int) *SimpleHNSW
NewSimpleHNSW creates a new simplified HNSW index
func (*SimpleHNSW) Add ¶
func (h *SimpleHNSW) Add(id string, vector []float32) error
Add inserts a vector into the HNSW index
func (*SimpleHNSW) Remove ¶
func (h *SimpleHNSW) Remove(nodeID string)
Remove removes a node from the index
func (*SimpleHNSW) Search ¶
func (h *SimpleHNSW) Search(query []float32, k int) []searchCandidate
Search performs HNSW search
type TraversalOptions ¶
type TraversalOptions struct {
MaxDepth int `json:"max_depth"`
EdgeTypes []string `json:"edge_types,omitempty"`
NodeTypes []string `json:"node_types,omitempty"`
Direction string `json:"direction"` // "out", "in", "both"
Limit int `json:"limit"`
}
TraversalOptions defines options for graph traversal
type TriplePattern ¶ added in v2.16.0
type TriplePattern struct {
Subject *RDFTerm `json:"subject,omitempty"`
Predicate *RDFTerm `json:"predicate,omitempty"`
Object *RDFTerm `json:"object,omitempty"`
Graph *RDFTerm `json:"graph,omitempty"`
Inferred *bool `json:"inferred,omitempty"`
Limit int `json:"limit,omitempty"`
}
TriplePattern filters triple lookup operations. Nil fields behave as wildcards.