search

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package search runs ripgrep against a Logseq graph and parses its JSON output into structured hits. It performs process I/O and decoding so the UI layer can consume plain []Hit values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hit

type Hit struct {
	FilePath string
	Line     int
	Context  string
	// Matches are byte offsets within Context that the query matched, so the
	// view can emphasise them in the rendered list.
	Matches []Span
}

Hit is one ripgrep result row.

func Mentions

func Mentions(graphPath, name string) ([]Hit, error)

Mentions finds whole-word, case-insensitive, literal occurrences of name across pages/ and journals/. Used to detect unlinked references to a page; word boundaries keep "Go" from matching "Google", and -F treats names with regex metacharacters literally.

func Run

func Run(graphPath, query string) ([]Hit, error)

Run executes ripgrep for query against <graphPath>/pages and <graphPath>/journals and returns the parsed hits. It returns (nil, nil) when neither subdirectory exists. A ripgrep exit code of 1 (no matches) is treated as success.

type Span

type Span struct {
	Start, End int
}

Span is a [Start, End) byte range inside Hit.Context.

Jump to

Keyboard shortcuts

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