searchnotes

package
v1.47.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 14 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 nor filter 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 Filter added in v1.3.2

type Filter struct {
	Scope
	MaxLength     int       // content (title line included) of at most that many characters; 0: any length
	Untagged      bool      // notes with no tag
	UpdatedBefore time.Time // notes last changed (or created, never changed) before it, the oldest first without a text; zero: any date
	NotText       string    // notes whose title and content do not hold it, whatever its case; empty: none left out
	EmptySections bool      // notes with a heading followed by nothing up to one of its level or higher, or the end
}

Filter keeps the notes of a search, with or without a text: what an agent sorting the account reads first.

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"`
	// The dates of the note, for a tile as a folder shows it.
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at,omitzero" binding:"optional"`
	// With the empty_sections filter, the heading lines of the sections left empty.
	EmptySections []string `json:"empty_sections,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, filter Filter, 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 and passing the content filters of filter (NotText, MaxLength, EmptySections; the others are the caller's): limit of them from offset, every one when limit is 0. No text nor content filter: 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 (none with a content filter: all are opened, so the total is exact), 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.

type Scope added in v1.11.0

type Scope struct {
	TagsAll        []string // tag ids the notes all carry
	TagsAny        []string // tag ids the notes carry at least one of
	TagsNone       []string // tag ids the notes carry none of
	Folders        []string // folder ids holding the notes, in their subfolders too
	ExcludeFolders bool     // the notes out of Folders instead
}

Scope keeps the notes by their tags and folders, every list left empty keeping them all: Idée AND (Cuisine OR Boisson) is TagsAll [Idée] and TagsAny [Cuisine, Boisson].

func (Scope) Where added in v1.11.0

func (s Scope) Where(ctx context.Context) (string, []any)

Where gives the conditions on i (items) keeping the notes of the scope, to add to a WHERE, and their arguments.

Jump to

Keyboard shortcuts

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