searchnotes

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoValue = errors.New("no text to search")

Functions

func Candidates

func Candidates(ctx context.Context, db bun.IDB, text string) (string, []any, []int16, error)

Candidates indexes the notes written since the last search, then gives the condition on mn (metadata_notes) that keeps the notes holding every gram of text, and those grams for mn.headings: a few more share them, the caller checks the text once opened. None for a single letter: every note, and no grams. TODO: a 2-letter text ("go") opens about a note in 30 more than hold it (16-bit blinds), fine at 50,000 notes.

func Cut

func Cut(line string, at int) string

Cut is a content line cut to snippetWidth around the byte at, with … where cut.

func Process

func Process(ctx context.Context, db bun.IDB, text string) *run

func Snippet

func Snippet(content, text string) string

Snippet is the first content line containing text, cut around it; the first line when only the title matched.

Types

type Match

type Match struct {
	ID       string `json:"id"`
	Title    string `json:"title"`
	Path     string `json:"path"`
	Snippet  string `json:"snippet"`
	Readonly bool   `json:"readonly,omitempty" binding:"optional"`
}

Match is a note containing the text, with the content line where it was found.

func Matches

func Matches(ctx context.Context, db bun.IDB, tree domain.Tree, ids []string, text string, limit, offset int) ([]Match, int, error)

Matches opens the notes of ids, in their order, and keeps those holding text in their title or content whatever its case: limit of them from offset, every one when limit is 0. No text: every note, none opened for its content. The index gives a few notes that do not hold the text, so they are opened until the page is full, not all of them: the total counts the matches met and the notes left unopened, and a page costs the ones before it. TODO: the last pages of a search with tens of thousands of matches open them all (1 s at 50,000 notes), as every page did; a cursor instead of an offset if they are ever read.

Jump to

Keyboard shortcuts

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