pub struct SearchQuery { /* private fields */ }Expand description
Query builder for searching notes.
Use this builder to configure note search with flexible filtering, sorting, and limits. By default, searches both title and content, returns up to 50 results sorted by most recently modified, and excludes trashed and archived notes.
§Examples
let db = BearDb::new()?;
// Search in both title and content (default)
let notes = db.search(SearchQuery::new("rust"))?;
// Search only in titles
let notes = db.search(
SearchQuery::new("rust")
.title_only()
)?;
// Search only in content
let notes = db.search(
SearchQuery::new("rust")
.content_only()
)?;
// Complex search with custom options
let notes = db.search(
SearchQuery::new("programming")
.title_only()
.limit(20)
.sort_by(SortOn::Title.asc())
.include_archived()
)?;
// Case-sensitive search
let notes = db.search(
SearchQuery::new("Rust")
.case_sensitive()
)?;Implementations§
Source§impl SearchQuery
impl SearchQuery
Sourcepub fn new(query: impl Into<String>) -> Self
pub fn new(query: impl Into<String>) -> Self
Create a new search with the given query string.
By default:
- Searches both title and content
- Case-insensitive search
- Limit: 50 results
- Sort: Most recently modified first
- Excludes trashed and archived notes
Sourcepub fn title_only(self) -> Self
pub fn title_only(self) -> Self
Search only in note titles (excludes content)
Sourcepub fn content_only(self) -> Self
pub fn content_only(self) -> Self
Search only in note content (excludes titles)
Sourcepub fn title_and_content(self) -> Self
pub fn title_and_content(self) -> Self
Search in both title and content (default)
Sourcepub fn case_sensitive(self) -> Self
pub fn case_sensitive(self) -> Self
Enable case-sensitive search (default is case-insensitive)
Sourcepub fn include_trashed(self) -> Self
pub fn include_trashed(self) -> Self
Include trashed notes in results
Sourcepub fn include_archived(self) -> Self
pub fn include_archived(self) -> Self
Include archived notes in results
Sourcepub fn include_all(self) -> Self
pub fn include_all(self) -> Self
Include both trashed and archived notes in results
Trait Implementations§
Source§impl Clone for SearchQuery
impl Clone for SearchQuery
Source§fn clone(&self) -> SearchQuery
fn clone(&self) -> SearchQuery
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SearchQuery
impl RefUnwindSafe for SearchQuery
impl Send for SearchQuery
impl Sync for SearchQuery
impl Unpin for SearchQuery
impl UnwindSafe for SearchQuery
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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