attribute_search_engine

Struct SearchEngine

Source
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>

Source

pub fn new() -> Self

Creates a new SearchEngine.

§Example
use attribute_search_engine::SearchEngine;

let engine = SearchEngine::<usize>::new();
Source

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);
Source

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.

Source

pub fn query_from_str(&self, query_str: &str) -> Result<Query>

Trait Implementations§

Source§

impl<P: Eq + Hash + Clone> Default for SearchEngine<P>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.