Documentation
¶
Overview ¶
Package search provides full-text grep-style search over vault files.
Index ¶
- func BuildRoles(todoSym, doneSym string, states []string) map[string]string
- func HasOperators(query string) bool
- func LineMatchesAll(tokens []Token, line string, roles map[string]string) bool
- func LineMatchesGroups(line string, groups [][]Token, hasXor bool, roles map[string]string) bool
- func ScopeMatchLines(tok Token, lines []string, anchorOnly bool) []int
- func SplitQueryGroups(toks []Token) (groups [][]Token, hasXor bool)
- func StripVaultPrefix(path string, cfg *config.Config) string
- type FileMatch
- type Result
- type SubTerm
- type Token
- type TokenKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRoles ¶ added in v1.7.0
BuildRoles returns a role-name -> symbol map for the standard task roles, using the same checkbox configuration as the viewer.
func HasOperators ¶ added in v1.7.0
HasOperators reports whether query contains any structured operator token. Plain-text queries return false and can be handled by the normal FTS path.
func LineMatchesAll ¶ added in v1.7.0
LineMatchesAll returns true when line satisfies all tokens.
func LineMatchesGroups ¶ added in v1.7.0
func ScopeMatchLines ¶ added in v1.7.0
ScopeMatchLines returns line indices satisfying the scope token over lines.
func SplitQueryGroups ¶ added in v1.7.0
SplitQueryGroups splits tokens on OR/XOR separators into AND-groups. hasXor is true only when XOR appears and OR does not.
Types ¶
type FileMatch ¶
FileMatch represents a file that contains matches with its first match for context.
type SubTerm ¶ added in v1.7.0
SubTerm is a single term within a scope operator argument. Neg=true means the term must NOT appear.
type Token ¶ added in v1.7.0
type Token struct {
Kind TokenKind
Value string // text for TokenText/TokenNeg, role name for TokenTaskRole, tag for TokenTag
SubQuery string // optional trailing text filter for task operators
SubTerms []SubTerm // non-nil for TokenSection/Block/Subtask
}
Token is one parsed unit of a search query.
func ParseQuery ¶ added in v1.7.0
ParseQuery parses a full search query into tokens. Returns nil for an empty query.
type TokenKind ¶ added in v1.7.0
type TokenKind int
TokenKind classifies a single parsed search token.
const ( TokenText TokenKind = iota // plain word or quoted phrase (must match) TokenNeg // -term: line must NOT contain value TokenTask // task: - any checkbox line TokenTaskRole // task-<role>: - checkbox with specific role symbol TokenTag // tag:<name> - line contains #<name> TokenSection // section:(A B) - sub-terms must co-occur in same heading section TokenBlock // block:(A B) - sub-terms must co-occur in same paragraph TokenSubtask // subtask:(A B) - line is a subtask of a task matching sub-terms TokenOr // separator: OR keyword between AND-groups TokenXor // separator: XOR keyword between AND-groups )