[][src]Struct simsearch::SearchOptions

pub struct SearchOptions { /* fields omitted */ }

Options and flags that configuring the search engine.

Examples

use simsearch::{SearchOptions, SimSearch};

let mut engine: SimSearch<usize> = SimSearch::new_with(
    SearchOptions::new().case_sensitive(true));

Implementations

impl SearchOptions[src]

pub fn new() -> Self[src]

Creates a default configuration.

pub fn case_sensitive(self, case_sensitive: bool) -> Self[src]

Sets whether search engine is case sensitive or not.

Defaults to false.

pub fn stop_whitespace(self, stop_whitespace: bool) -> Self[src]

Sets the whether search engine splits tokens on whitespace or not. The whitespace here includes tab, returns and so forth.

See also std::str::split_whitespace().

Defaults to true.

pub fn stop_words(self, stop_words: &'static [&'static str]) -> Self[src]

Sets the custom token stop word.

This option enables tokenizer to split contents and search words by the extra list of custom stop words.

Defaults to &[].

Examples

use simsearch::{SearchOptions, SimSearch};

let mut engine: SimSearch<usize> = SimSearch::new_with(
    SearchOptions::new().stop_words(&["/", "\\"]));

engine.insert(1, "the old/man/and/the sea");

let results = engine.search("old");

assert_eq!(results, &[1]);

pub fn threshold(self, threshold: f64) -> Self[src]

Sets the threshold for search scoring.

Search results will be sorted by their Jaro winkler similarity scores. Scores ranges from 0 to 1 where the 1 indicates the most relevant. Only the entries with scores greater than the threshold will be returned.

Defaults to 0.8.

pub fn levenshtein(self, levenshtein: bool) -> Self[src]

Sets whether Levenshtein distance, which is SIMD-accelerated, should be used instead of the default Jaro-Winkler distance.

The implementation of Levenshtein distance is very fast but cannot handle Unicode strings, unlike the default Jaro-Winkler distance. The strings are treated as byte slices with Levenshtein distance, which means that the calculated score may be incorrectly lower for Unicode strings, where each character is represented with multiple bytes.

Defaults to false.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.