query

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockMatch

type BlockMatch struct {
	NodeID      string
	NodeTitle   string
	SectionName string
	BlockIndex  int
	Block       domain.Block
}

BlockMatch represents a matched block with its parent context.

type FilterCriteria

type FilterCriteria struct {
	Kind         *string           // Filter by node kind (exact match)
	Status       *string           // Filter by node status (exact match)
	Tags         []string          // Filter by tags (node must have all specified tags)
	BlockType    *string           // Filter by block type within content sections
	FieldFilters map[string]string // Filter by block field key=value (AND logic)
}

FilterCriteria defines the criteria for filtering nodes and blocks.

type FollowResult

type FollowResult struct {
	Value    string       // The followed value (e.g., "Planks")
	RefCount int          // How many source blocks reference this value
	Matches  []BlockMatch // Blocks in target types that provide this value
}

FollowResult groups followed blocks by their source value.

type FollowTarget

type FollowTarget struct {
	BlockType string
	Field     string
}

FollowTarget specifies a block type and field to follow into.

type QueryEngine

type QueryEngine struct {
}

QueryEngine provides query and search capabilities for nodes.

func New

func New() *QueryEngine

New creates a new QueryEngine instance.

func (*QueryEngine) Filter

func (qe *QueryEngine) Filter(nodes []domain.Node, criteria FilterCriteria) []domain.Node

Filter returns nodes that match the given criteria. Multiple criteria are combined with AND logic. Empty criteria returns all nodes.

func (*QueryEngine) FilterBlocks

func (qe *QueryEngine) FilterBlocks(nodes []domain.Node, criteria FilterCriteria) []BlockMatch

FilterBlocks returns blocks that match the given criteria, including block-level filters. Node-level filters (Kind, Status, Tags) narrow which nodes are searched. BlockType and FieldFilters filter blocks within matching nodes.

func (*QueryEngine) FollowBlocks

func (qe *QueryEngine) FollowBlocks(sourceMatches []BlockMatch, followField string, targets []FollowTarget, allNodes []domain.Node, blockTypes map[string]config.BlockTypeConfig) ([]FollowResult, error)

FollowBlocks takes matched source blocks, extracts values from the follow field, and finds blocks in target types that provide those values. If targets is nil, it looks up the ref config for the source block type. Returns results grouped by followed value, sorted alphabetically.

func (*QueryEngine) Search

func (qe *QueryEngine) Search(nodes []domain.Node, term string) []domain.Node

Search returns nodes that contain the search term in their title or summary. Search is case-insensitive and supports partial matches. Empty search term returns all nodes.

Jump to

Keyboard shortcuts

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