pub struct TrigramQuery {
pub or_groups: Vec<Vec<Trigram>>,
pub and_clauses: Vec<Vec<Trigram>>,
}Expand description
A boolean query over trigrams supporting two complementary shapes:
or_groupsis disjunctive normal form (DNF): each inner group is an AND of trigrams and the outer set is an OR of groups. Used for exact literals and regex required-literal alternations.and_clausesis conjunctive normal form (CNF): each inner clause is an OR of trigrams and a document must satisfy every clause. Used for case-insensitive literals, where each needle position contributes the OR of its case variants.
A document is a candidate if it satisfies the DNF part (or the DNF part is empty) and every CNF clause. An empty query means “scan everything”.
Fields§
§or_groups: Vec<Vec<Trigram>>§and_clauses: Vec<Vec<Trigram>>Implementations§
Source§impl TrigramQuery
impl TrigramQuery
Sourcepub fn is_unconstrained(&self) -> bool
pub fn is_unconstrained(&self) -> bool
True when no usable trigram constraints exist and all documents are candidates. A group/clause that is empty means that part can’t filter.
pub fn from_literal(needle: &[u8]) -> TrigramQuery
Sourcepub fn from_literal_ci(needle: &[u8]) -> TrigramQuery
pub fn from_literal_ci(needle: &[u8]) -> TrigramQuery
Build a case-insensitive literal query. Each 3-byte window of the needle becomes a CNF clause listing every ASCII-case variant of that window, so the trigram index can still prune candidates without false negatives.
A window is only usable as a clause when all three of its bytes are
ASCII-case-safe (see [ci_safe]): otherwise the case-insensitive
matcher (Unicode-aware) could match bytes we did not enumerate, and
requiring the ASCII trigrams would drop real matches. Unsafe windows are
skipped, which only widens the candidate set. If no usable window remains,
the query is unconstrained and every document is scanned.
Trait Implementations§
Source§impl Clone for TrigramQuery
impl Clone for TrigramQuery
Source§fn clone(&self) -> TrigramQuery
fn clone(&self) -> TrigramQuery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TrigramQuery
impl Debug for TrigramQuery
Source§impl Default for TrigramQuery
impl Default for TrigramQuery
Source§fn default() -> TrigramQuery
fn default() -> TrigramQuery
Auto Trait Implementations§
impl Freeze for TrigramQuery
impl RefUnwindSafe for TrigramQuery
impl Send for TrigramQuery
impl Sync for TrigramQuery
impl Unpin for TrigramQuery
impl UnsafeUnpin for TrigramQuery
impl UnwindSafe for TrigramQuery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more