cypher

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Variable string // "f"
	Property string // "name"
	Operator string // "=", "=~", "CONTAINS", "STARTS WITH", ">", "<", ">=", "<="
	Value    string // the comparison value
}

Condition is a single property comparison.

type Executor

type Executor struct {
	Store *store.Store
	// contains filtered or unexported fields
}

Executor runs Cypher execution plans against a store.

func (*Executor) Execute

func (e *Executor) Execute(query string) (*Result, error)

Execute parses, plans, and executes a Cypher query across all projects.

type ExpandRelationship

type ExpandRelationship struct {
	FromVar   string // source variable (already bound)
	ToVar     string // target variable (to bind)
	RelVar    string // optional relationship variable (to bind edge)
	ToLabel   string // optional label filter on target
	ToProps   map[string]string
	EdgeTypes []string // required edge types
	Direction string   // "outbound", "inbound", "any"
	MinHops   int
	MaxHops   int
}

ExpandRelationship follows edges from bound nodes to match target nodes.

type FilterWhere

type FilterWhere struct {
	Conditions []Condition
	Operator   string // "AND" or "OR"
}

FilterWhere applies WHERE conditions to the bindings.

type Lexer

type Lexer struct {
	// contains filtered or unexported fields
}

Lexer tokenizes a Cypher query string.

type MatchClause

type MatchClause struct {
	Pattern *Pattern
}

MatchClause holds the MATCH pattern.

type NodePattern

type NodePattern struct {
	Variable string            // e.g. "f"
	Label    string            // e.g. "Function" (optional)
	Props    map[string]string // inline property filters (optional)
}

NodePattern matches a graph node with optional label and inline properties.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser converts a token stream into an AST.

type Pattern

type Pattern struct {
	Elements []PatternElement
}

Pattern is a sequence of alternating nodes and relationships.

type PatternElement

type PatternElement interface {
	// contains filtered or unexported methods
}

PatternElement is either a NodePattern or a RelPattern.

type Plan

type Plan struct {
	Steps      []PlanStep
	ReturnSpec *ReturnClause
}

Plan represents an execution plan for a parsed Cypher query.

func BuildPlan

func BuildPlan(q *Query) (*Plan, error)

BuildPlan converts a parsed Query AST into an execution Plan.

type PlanStep

type PlanStep interface {
	// contains filtered or unexported methods
}

PlanStep is a single step in the execution plan.

type Query

type Query struct {
	Match  *MatchClause
	Where  *WhereClause
	Return *ReturnClause
}

Query represents a parsed Cypher query.

func Parse

func Parse(input string) (*Query, error)

Parse tokenizes and parses a Cypher query string into an AST.

type RelPattern

type RelPattern struct {
	Variable  string   // (optional)
	Types     []string // relationship types, e.g. ["CALLS", "HTTP_CALLS"]
	Direction string   // "outbound", "inbound", "any"
	MinHops   int      // for variable-length, default 1
	MaxHops   int      // for variable-length, default 1 (0 means unbounded)
}

RelPattern matches a graph relationship with optional types, direction, and hops.

type Result

type Result struct {
	Columns []string         `json:"columns"`
	Rows    []map[string]any `json:"rows"`
}

Result holds the tabular output of a query.

type ReturnClause

type ReturnClause struct {
	Items    []ReturnItem
	OrderBy  string // "f.name" (optional)
	OrderDir string // "ASC" or "DESC"
	Limit    int    // 0 means no limit
	Distinct bool
}

ReturnClause specifies which data to return from the query.

type ReturnItem

type ReturnItem struct {
	Variable string // "f"
	Property string // "name" (empty = return whole node)
	Alias    string // "AS call_count" (optional)
	Func     string // "COUNT" (optional aggregation)
}

ReturnItem is a single item in the RETURN clause.

type ScanNodes

type ScanNodes struct {
	Variable string
	Label    string
	Props    map[string]string // inline property filters
}

ScanNodes finds nodes matching label and/or inline property filters.

type Token

type Token struct {
	Type  TokenType
	Value string
	Pos   int // byte offset in the input
}

Token is a single lexer token.

func Lex

func Lex(input string) ([]Token, error)

Lex tokenizes the input string into a slice of tokens.

func (Token) String

func (t Token) String() string

type TokenType

type TokenType int

TokenType classifies a lexer token.

const (
	// Keywords
	TokMatch    TokenType = iota // MATCH
	TokWhere                     // WHERE
	TokReturn                    // RETURN
	TokOrder                     // ORDER
	TokBy                        // BY
	TokLimit                     // LIMIT
	TokAnd                       // AND
	TokOr                        // OR
	TokAs                        // AS
	TokDistinct                  // DISTINCT
	TokCount                     // COUNT
	TokContains                  // CONTAINS
	TokStarts                    // STARTS
	TokWith                      // WITH
	TokNot                       // NOT
	TokAsc                       // ASC
	TokDesc                      // DESC

	// Symbols
	TokLParen   // (
	TokRParen   // )
	TokLBracket // [
	TokRBracket // ]
	TokDash     // -
	TokGT       // >
	TokLT       // <
	TokColon    // :
	TokDot      // .
	TokLBrace   // {
	TokRBrace   // }
	TokStar     // *
	TokComma    // ,
	TokEQ       // =
	TokRegex    // =~
	TokGTE      // >=
	TokLTE      // <=
	TokPipe     // |
	TokDotDot   // ..

	// Literals
	TokIdent  // identifier
	TokString // "..." or '...'
	TokNumber // integer

	TokEOF // end of input
)

type WhereClause

type WhereClause struct {
	Conditions []Condition
	Operator   string // "AND" or "OR"
}

WhereClause holds filter conditions joined by AND/OR.

Jump to

Keyboard shortcuts

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