pub struct SearchEngine {
conn: Connection,
working_directory: PathBuf,
host_set: Vec<BString>,
matcher: Matcher,
result_limit: usize,
}Expand description
Search engine that combines SQLite queries with nucleo fuzzy matching
Fields§
§conn: Connection§working_directory: PathBuf§host_set: Vec<BString>§matcher: Matcher§result_limit: usizeImplementations§
Source§impl SearchEngine
impl SearchEngine
pub fn new( conn: Connection, working_directory: PathBuf, host_set: Vec<BString>, result_limit: usize, ) -> Self
Sourcepub fn primary_hostname(&self) -> &BString
pub fn primary_hostname(&self) -> &BString
Get the primary (current live) hostname – used for display
Sourcepub fn is_this_host(&self, hostname: &BString) -> bool
pub fn is_this_host(&self, hostname: &BString) -> bool
Check if a hostname is in this host’s set (current + aliases)
Sourcefn push_query_conditions(
query: Option<&RecallQuery>,
where_conditions: &mut Vec<String>,
params: &mut Vec<String>,
)
fn push_query_conditions( query: Option<&RecallQuery>, where_conditions: &mut Vec<String>, params: &mut Vec<String>, )
Append one LIKE condition per prefilter pattern of query. The
patterns come from RecallQuery, which owns the guarantee that they
accept every row the fuzzy stage could match.
Sourcepub fn load_entries(
&self,
filter_mode: FilterMode,
host_filter: HostFilter,
query: Option<&RecallQuery>,
) -> Result<Vec<HistoryEntry>>
pub fn load_entries( &self, filter_mode: FilterMode, host_filter: HostFilter, query: Option<&RecallQuery>, ) -> Result<Vec<HistoryEntry>>
Load history entries from the database, optionally narrowed by the query’s DB prefilter.
Sourcefn recall_query(
&self,
filter_mode: FilterMode,
host_filter: HostFilter,
query: Option<&RecallQuery>,
) -> (String, Vec<String>)
fn recall_query( &self, filter_mode: FilterMode, host_filter: HostFilter, query: Option<&RecallQuery>, ) -> (String, Vec<String>)
Build the recall SQL and its bound parameters. Oversamples by 3x and
relies on the caller’s deduplicate_entries() for dedup – avoids the
expensive CTE self-join that caused double table scans at scale. The
ORDER BY must stay satisfiable by history_start_time so LIMIT bounds
the work to the window rather than the table (see the plan tests).
fn row_to_entry(&self, row: &Row<'_>) -> Result<HistoryEntry>
Sourcepub fn delete_entries_by_command(&self, command: &str) -> Result<usize>
pub fn delete_entries_by_command(&self, command: &str) -> Result<usize>
Delete all history entries matching a command (trimmed), since the recall list is deduplicated by command text. Returns the number of rows deleted.
Sourcepub fn result_limit(&self) -> usize
pub fn result_limit(&self) -> usize
Get the configured result limit
Sourcepub fn working_directory(&self) -> &PathBuf
pub fn working_directory(&self) -> &PathBuf
Get the working directory for display
Sourcepub fn filter_entries(
&mut self,
entries: &[HistoryEntry],
query: &RecallQuery,
) -> Vec<(usize, Vec<u32>)>
pub fn filter_entries( &mut self, entries: &[HistoryEntry], query: &RecallQuery, ) -> Vec<(usize, Vec<u32>)>
Filter entries using nucleo fuzzy matching. Returns (index, highlight_positions) sorted by combined score: nucleo’s fuzzy score (word-boundary matches favored, gaps penalized) plus a recency boost so freshly-used commands outrank stale ones at similar match quality. Original-index ascending breaks remaining ties (more recent first).
Auto Trait Implementations§
impl !Freeze for SearchEngine
impl !RefUnwindSafe for SearchEngine
impl !Sync for SearchEngine
impl !UnwindSafe for SearchEngine
impl Send for SearchEngine
impl Unpin for SearchEngine
impl UnsafeUnpin for SearchEngine
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> 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