ftsquery

package
v0.49.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package ftsquery builds safe FTS5 MATCH expressions from free text. It is shared by every feature that queries an FTS5 index (memory search, recally article search) so the escaping rules live in exactly one place.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildMatchQuery

func BuildMatchQuery(text string) string

BuildMatchQuery converts free text into an FTS5 MATCH expression for a trigram-tokenized index. Tokens (runs of letters/digits/underscore) are individually quoted so FTS5 query operators in user input (*, -, :, parens) can never break the query, and OR-joined for recall — BM25 still ranks multi-term hits higher. Tokens shorter than 3 runes are dropped: the trigram tokenizer silently matches nothing for them, so they contribute zero recall. Returns "" when no usable token remains; callers must skip MATCH then (and may fall back to a LIKE scan, see EscapeLike).

func EscapeLike

func EscapeLike(s string) string

EscapeLike escapes LIKE wildcards (%, _) and the escape character itself so user text can be embedded in a `LIKE ? ESCAPE '\'` pattern as a literal substring.

Types

This section is empty.

Jump to

Keyboard shortcuts

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