pub struct SearchEngine<P> { /* private fields */ }Expand description
A SearchEngine is a wrapper around a collection of search indices that can process complex queries involving multiple indices.
It can also create queries from strings that are tailored to the existing indices.
§Example
A complete example can be found on the front page of this crate.
Implementations§
Source§impl<P: Eq + Hash + Clone> SearchEngine<P>
impl<P: Eq + Hash + Clone> SearchEngine<P>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new SearchEngine.
§Example
use attribute_search_engine::SearchEngine;
let engine = SearchEngine::<usize>::new();Sourcepub fn add_index<T: SearchIndex<P> + 'static>(&mut self, name: &str, index: T)
pub fn add_index<T: SearchIndex<P> + 'static>(&mut self, name: &str, index: T)
Add a new index to this search engine.
§Example
use attribute_search_engine::{SearchEngine, SearchIndexHashMap};
let mut index = SearchIndexHashMap::<_, String>::new();
// Fill index here...
let mut engine = SearchEngine::<usize>::new();
engine.add_index("attribute", index);Sourcepub fn search(&self, query: &Query) -> Result<HashSet<P>>
pub fn search(&self, query: &Query) -> Result<HashSet<P>>
Run a query on the search engine.
The result is a HashSet of all row ids / primary ids with rows that matched the query.
pub fn query_from_str(&self, query_str: &str) -> Result<Query>
Trait Implementations§
Auto Trait Implementations§
impl<P> Freeze for SearchEngine<P>
impl<P> !RefUnwindSafe for SearchEngine<P>
impl<P> !Send for SearchEngine<P>
impl<P> !Sync for SearchEngine<P>
impl<P> Unpin for SearchEngine<P>
impl<P> !UnwindSafe for SearchEngine<P>
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