Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoValue = errors.New("no text nor filter to search")
Functions ¶
func Candidates ¶
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.
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"`
// 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].