pub struct SearchQuery<'a> { /* private fields */ }Expand description
A composable query for filtering notes in a vault.
§Filter semantics
and_glob: AND — note’s relative path matches one of these patternsor_glob: OR — note’s relative path matches one of these patternsand_has_id: OR — has this IDor_has_id: OR — has one of these IDsand_has_tag: AND — note has all of these tagsor_has_tag: OR — note has one of these tagand_has_alias: AND — note has all of these aliases (case insensitive)or_has_alias: OR — note has any of these aliases (case insensitive)and_title_contains: AND — title contains all of these substringsor_title_contains: OR — title contains any of these substringsand_alias_contains: AND — all of these substrings must match some aliasor_alias_contains: OR — one of these substrings matches some aliasand_content_contains: AND — content contains all of these substrings (case-sensitive)or_content_contains: OR — content contains any of these substrings (case-sensitive)and_content_matches: AND — content matches all of these patternsor_content_matches: OR — content matches any of these patterns
Implementations§
Source§impl SearchQuery<'static>
impl SearchQuery<'static>
pub fn new(root: impl AsRef<Path>) -> Self
Sourcepub fn with_loaded_notes<'a>(
self,
notes: &'a HashMap<PathBuf, Note>,
) -> SearchQuery<'a>
pub fn with_loaded_notes<'a>( self, notes: &'a HashMap<PathBuf, Note>, ) -> SearchQuery<'a>
Provide in-memory notes to use instead of their on-disk counterparts.
Each note’s note.path is matched against the vault’s note paths on disk. Notes whose
paths exist on disk shadow the disk version; notes with no on-disk counterpart are included
as additional candidates. In-memory notes are assumed to have content populated whenever
content filters (e.g. and_content_contains) are used.
Source§impl<'a> SearchQuery<'a>
impl<'a> SearchQuery<'a>
Sourcepub fn and_glob(self, pattern: impl Into<String>) -> Self
pub fn and_glob(self, pattern: impl Into<String>) -> Self
Note path must match this glob pattern (matched against the note’s path relative to the vault root).
Sourcepub fn or_glob(self, pattern: impl Into<String>) -> Self
pub fn or_glob(self, pattern: impl Into<String>) -> Self
Note path could match this glob pattern (matched against the note’s path relative to the vault root).
Sourcepub fn and_has_id(self, id: impl Into<String>) -> Self
pub fn and_has_id(self, id: impl Into<String>) -> Self
Note must have this ID (case-sensitive by default).
Sourcepub fn or_has_id(self, id: impl Into<String>) -> Self
pub fn or_has_id(self, id: impl Into<String>) -> Self
Note could have this ID (case-sensitive by default).
Sourcepub fn and_has_tag(self, tag: impl Into<String>) -> Self
pub fn and_has_tag(self, tag: impl Into<String>) -> Self
Note must have this tag (case-insensitive by default).
Sourcepub fn or_has_tag(self, tag: impl Into<String>) -> Self
pub fn or_has_tag(self, tag: impl Into<String>) -> Self
Note could have this tag (case-insensitive by default).
Sourcepub fn and_title_contains(self, s: impl Into<String>) -> Self
pub fn and_title_contains(self, s: impl Into<String>) -> Self
Must title must contain this substring (smart case-sensitive by default).
Sourcepub fn or_title_contains(self, s: impl Into<String>) -> Self
pub fn or_title_contains(self, s: impl Into<String>) -> Self
Must title could contain this substring (smart case-sensitive by default).
Sourcepub fn and_has_alias(self, alias: impl Into<String>) -> Self
pub fn and_has_alias(self, alias: impl Into<String>) -> Self
Note must have this alias (smart case-sensitive by default).
Sourcepub fn or_has_alias(self, alias: impl Into<String>) -> Self
pub fn or_has_alias(self, alias: impl Into<String>) -> Self
Note could have this alias (smart case-sensitive by default).
Sourcepub fn and_alias_contains(self, s: impl Into<String>) -> Self
pub fn and_alias_contains(self, s: impl Into<String>) -> Self
Substring must match against any of the note’s aliases (smart case-sensitive by default).
Sourcepub fn or_alias_contains(self, s: impl Into<String>) -> Self
pub fn or_alias_contains(self, s: impl Into<String>) -> Self
Substring could match against any of the note’s aliases (smart case-sensitive by default).
Sourcepub fn and_content_contains(self, s: impl Into<String>) -> Self
pub fn and_content_contains(self, s: impl Into<String>) -> Self
Note body must contain this string (smart case-sensitive by default).
Sourcepub fn or_content_contains(self, s: impl Into<String>) -> Self
pub fn or_content_contains(self, s: impl Into<String>) -> Self
Note body could contain this string (smart case-sensitive by default).
Sourcepub fn and_content_matches(self, pattern: impl Into<String>) -> Self
pub fn and_content_matches(self, pattern: impl Into<String>) -> Self
Regex body must match this pattern (smart case-sensitive by default).
Sourcepub fn or_content_matches(self, pattern: impl Into<String>) -> Self
pub fn or_content_matches(self, pattern: impl Into<String>) -> Self
Regex body could match this pattern (smart case-sensitive by default).
Sourcepub fn and_links_to(self, note: Note) -> Self
pub fn and_links_to(self, note: Note) -> Self
Has a link to this note
Sourcepub fn or_links_to(self, note: Note) -> Self
pub fn or_links_to(self, note: Note) -> Self
May link to this note
Sourcepub fn case_sensitive(self) -> Self
pub fn case_sensitive(self) -> Self
Execute the search case-sensitively.
Sourcepub fn ignore_case(self) -> Self
pub fn ignore_case(self) -> Self
Execute the search case-insensitively.
Sourcepub fn smart_case(self) -> Self
pub fn smart_case(self) -> Self
Execute the search with smart case sensitivity: case-sensitive if the query contains any uppercase letters, otherwise case-insensitive.
pub fn sort_by(self, sort_order: SortOrder) -> Self
Auto Trait Implementations§
impl<'a> Freeze for SearchQuery<'a>
impl<'a> RefUnwindSafe for SearchQuery<'a>
impl<'a> Send for SearchQuery<'a>
impl<'a> Sync for SearchQuery<'a>
impl<'a> Unpin for SearchQuery<'a>
impl<'a> UnsafeUnpin for SearchQuery<'a>
impl<'a> UnwindSafe for SearchQuery<'a>
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