Skip to main content

Module query

Module query 

Source
Expand description

Turn a regex pattern into a boolean trigram query that every matching file must satisfy.

Soundness is the whole game: the query may be satisfied by files that don’t actually match (ripgrep filters those out), but it must never exclude a file that does match. We get this from regex-syntax’s literal extraction, which returns a complete over-approximation of a regex’s prefixes (or suffixes) or else reports that it cannot — in which case we fall back to “match everything” (Query::All).

Construction: every match starts with one of the extracted prefix literals AND ends with one of the suffix literals. Each is an independently necessary condition, so their conjunction is necessary. For a literal of length >= 3 we require all its trigrams (an AND); across the alternatives we OR; a literal shorter than 3 (or an unbounded literal set) carries no trigram constraint, collapsing that side to All. See docs/index-and-storage.md (section 2.3).

Structs§

Options
Options that affect how a pattern is parsed (mirroring the ripgrep flags that matter for literal extraction).

Enums§

Query
A boolean formula over trigrams. All means “no constraint” — scan everything (the safe fallback). Leaves are individual trigrams that must be present.