Enum indicium::simple::SearchType

source ·
pub enum SearchType {
    Live,
    And,
    Or,
    Keyword,
}
Expand description

Indicium simple search provides four types of search. The best search type that should be used really depends on your use-case: the nature of the data, the intent of the user, and the size of your data set.

Support for and and or keywords inside the search string is not currently planned for the simple search engine since the intent is to have a relatively simple implementation.

For more information on the setting the search type in a SearchIndex type see: SearchIndexBuilder or SearchIndex::new().

Variants§

§

Live

Interactive Live search allows for “search as you type.” It is a hybridization of autocomplete and search. This method will effectively search all of the autocompletion options and return the search results to the caller.

This search method accepts multiple keywords in the search string. The logical conjuction for multiple keywords is And. For example, a search of this that will only return records containing keywords both this and that. In other words, all keywords must be present in a record for it to be returned as a result.

You may change & control the ordering of your records by manually implementing the Ord trait for your K key.

This conjuction uses the most CPU resources because the search results must be gathered for several autocompletion options.

Modern Internet browsers often have a similar “type as you search” functionality in the address bar. Spotify also has a cool implementation of a similar feature.

§

And

This search method accepts multiple keywords in the search string. The logical conjuction for multiple keywords is And. For example, a search of this that will only return records containing keywords both this and that. In other words, all keywords must be present in a record for it to be returned as a result.

You may change & control the ordering of your records by manually implementing the Ord trait for your K key.

This conjuction uses less CPU resources than Or.

The And search feels more like “use my keywords to filter out the records I don’t want.” It’s likely a better choice for large collections because it uses less CPU resouces than Or.

Probably best suited in a filter widget.

§

Or

This search method accepts multiple keywords in the search string. The logical conjuction for multiple keywords is Or. For example, a search of this that will return records containing keywords this or that. In other words, any keyword can be present in a record for it to be returned as a result.

The results are returned in order of descending relevance. Records containing both keywords this and that will be the top results.

This conjuction uses more CPU resources than And because the keyword hits must be tallied and sorted.

If your collection contains less than 10,000 records, Or might be a good place to start. To me, Or effectively feels like “using these keywords, find a record I might want” which works well if there aren’t too many records.

Probably best suited for a search results screen.

§

Keyword

The search string is expected to only contain a single keyword. This is the lightest and fastest search type. It is good for compact interfaces, where records are very simple, and data-sets are quite small.

You may change & control the ordering of your records by manually implementing the Ord trait for your K key.

Probably best suited in a form widget.

Trait Implementations§

source§

impl Clone for SearchType

source§

fn clone(&self) -> SearchType

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SearchType

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for SearchType

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for SearchType

source§

fn cmp(&self, other: &SearchType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for SearchType

source§

fn eq(&self, other: &SearchType) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for SearchType

source§

fn partial_cmp(&self, other: &SearchType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for SearchType

source§

impl StructuralPartialEq for SearchType

Auto Trait Implementations§

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more