### Get Value by Key Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Retrieves a reference to the value associated with the provided key. ```rust use std::collections::BTreeMap; let mut map = BTreeMap::new(); map.insert(1, "a"); assert_eq!(map.get(&1), Some(&"a")); assert_eq!(map.get(&2), None); ``` -------------------------------- ### Implement Indexable for a custom struct Source: https://docs.rs/indicium/0.6.10/indicium/simple/trait.Indexable.html?search=u32+-%3E+bool Example implementation of the Indexable trait for a struct, converting fields into a vector of strings. ```rust struct MyStruct { title: String, year: u16, body: String, } impl Indexable for MyStruct { fn strings(&self) -> Vec { vec![ self.title.clone(), self.year.to_string(), self.body.clone(), ] } } ``` -------------------------------- ### keys Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Gets an iterator over the keys of the map, in sorted order. ```APIDOC pub fn keys(&self) -> Keys<'_, K, V> ``` -------------------------------- ### Access BTreeMap entry Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Gets the entry for a key to perform in-place manipulation. ```rust use std::collections::BTreeMap; let mut count: BTreeMap<&str, usize> = BTreeMap::new(); // count the number of occurrences of letters in the vec for x in ["a", "b", "a", "c", "a", "b"] { count.entry(x).and_modify(|curr| *curr += 1).or_insert(1); } assert_eq!(count["a"], 3); assert_eq!(count["b"], 2); assert_eq!(count["c"], 1); ``` -------------------------------- ### iter Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Gets an iterator over the entries of the map, sorted by key. ```APIDOC pub fn iter(&self) -> Iter<'_, K, V> ``` -------------------------------- ### values Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Gets an iterator over the values of the map, in order by key. ```APIDOC pub fn values(&self) -> Values<'_, K, V> ``` -------------------------------- ### Get Key-Value Pair Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Retrieves the stored key-value pair, useful when the lookup key type differs from the stored key type but maintains equivalent ordering. ```rust use std::cmp::Ordering; use std::collections::BTreeMap; #[derive(Clone, Copy, Debug)] struct S { id: u32, name: &'static str, // ignored by equality and ordering operations } impl PartialEq for S { fn eq(&self, other: &S) -> bool { self.id == other.id } } impl Eq for S {} impl PartialOrd for S { fn partial_cmp(&self, other: &S) -> Option { self.id.partial_cmp(&other.id) } } impl Ord for S { fn cmp(&self, other: &S) -> Ordering { self.id.cmp(&other.id) } } let j_a = S { id: 1, name: "Jessica" }; let j_b = S { id: 1, name: "Jess" }; let p = S { id: 2, name: "Paul" }; assert_eq!(j_a, j_b); let mut map = BTreeMap::new(); map.insert(j_a, "Paris"); assert_eq!(map.get_key_value(&j_a), Some((&j_a, &"Paris"))); assert_eq!(map.get_key_value(&j_b), Some((&j_a, &"Paris"))); // the notable case assert_eq!(map.get_key_value(&p), None); ``` -------------------------------- ### build Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndexBuilder.html Builds the SearchIndex instance. ```APIDOC ## pub fn build(self) -> SearchIndex ### Description Constructs and returns a SearchIndex instance based on the current configuration of the builder. ``` -------------------------------- ### Retrieve all records using dump keyword Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Demonstrates using the dump keyword to fetch a full listing of all registered records. ```rust if let Some(dump_keyword) = search_index.dump_keyword() { assert_eq!( search_index.search(&dump_keyword), [&0, &1, &2, &3, &4, &5, &6] ); } ``` -------------------------------- ### Initialize a new SearchIndex Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Creates a new SearchIndex instance with specific configuration parameters for search behavior, metrics, and keyword handling. ```rust let mut search_index = SearchIndex::::new( SearchType::Or, // Search type. AutocompleteType::Context, // Autocompletion type. Some(EddieMetric::Levenshtein), // String similarity metric type. Some(RapidfuzzMetric::Levenshtein), // String similarity metric type. Some(StrsimMetric::Levenshtein), // String similarity metric type. 3, // String similarity match length. 0.5, // String similarity minimum score. Some(vec![' ', '\n', '\r', '\t', ',', '.']), // Split characters. false, // Case sensitive? 1, // Minimum keyword length (in chars or codepoints.) 24, // Maximum keyword length (in chars or codepoints.) Some(24), // Maximum text length (in chars or codepoints.) Some(vec!["a".to_string(), "the".to_string()]), // Keyword exclusions. 5, // Maximum number of auto-complete options. 100, // Maximum number of search results. 40_960, // Maximum keys per keyword. Some("\0".to_string()), // Dump keyword. ); ``` -------------------------------- ### values_mut Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Gets a mutable iterator over the values of the map, in order by key. ```APIDOC pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ``` -------------------------------- ### Implement Autocompletion Source: https://docs.rs/indicium/0.6.10/indicium/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Configure and use the autocomplete method to provide search suggestions. ```rust let mut search_index: SearchIndex = SearchIndexBuilder::default() .autocomplete_type(AutocompleteType::Global) .exclude_keywords(None) .build(); search_index.insert(&0, &"apple"); search_index.insert(&1, &"ball"); search_index.insert(&3, &"bird"); search_index.insert(&4, &"birthday"); search_index.insert(&5, &"red"); let autocomplete_options: Vec = search_index.autocomplete("a very big bi"); assert_eq!( autocomplete_options, vec!["a very big bird", "a very big birthday"] ); // Demonstrating fuzzy matching: let autocomplete_options: Vec = search_index.autocomplete("a very big birf"); assert_eq!( autocomplete_options, vec!["a very big bird", "a very big birthday"] ); ``` -------------------------------- ### iter_mut Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Gets a mutable iterator over the entries of the map, sorted by key. ```APIDOC pub fn iter_mut(&mut self) -> IterMut<'_, K, V> ``` -------------------------------- ### Index a HashMap collection Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Demonstrates indexing a HashMap by using its String key as the SearchIndex key. ```rust let my_hash_map: HashMap = HashMap::new(); // In the case of a `HashMap` collection, we use the hash map's key as // the `SearchIndex` key. In our hypothetical example, we will use // MyStruct's `title` as a the key which is a `String` type. Therefore // we will instantiate `HashMap` as HashMap and // `SearchIndex` as `SearchIndex`. let mut search_index: SearchIndex = SearchIndex::default(); my_hash_map .iter() .for_each(|(key, value)| search_index.insert(key, value) ); ``` -------------------------------- ### Use Enum Keys for Universal Indexing Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Shows how to define an enum to act as a universal key for multiple collection types within a single SearchIndex. ```rust #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] enum CollectionKey { MyVecCollection(usize), MyHashMapCollection(String), } let search_index: SearchIndex = SearchIndex::default(); ``` -------------------------------- ### Get BTreeMap length Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Returns the number of elements currently stored in the map. ```rust use std::collections::BTreeMap; let mut a = BTreeMap::new(); assert_eq!(a.len(), 0); a.insert(1, "a"); assert_eq!(a.len(), 1); ``` -------------------------------- ### SearchIndex::new Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html Creates a new, empty SearchIndex instance with specified configuration parameters. ```APIDOC ## pub fn new(search_type: SearchType, autocomplete_type: AutocompleteType, eddie_metric: Option, rapidfuzz_metric: Option, strsim_metric: Option, fuzzy_length: usize, fuzzy_minimum_score: f64, split_pattern: Option>, case_sensitive: bool, minimum_keyword_length: usize, maximum_keyword_length: usize, maximum_string_length: Option, exclude_keywords: Option>, maximum_autocomplete_options: usize, maximum_search_results: usize, maximum_keys_per_keyword: usize, dump_keyword: Option) -> Self ### Description Makes a new, empty SearchIndex. It might be more convenient to use SearchIndex::default() or SearchIndexBuilder::default() to create a new search index. ``` -------------------------------- ### SearchIndexBuilder Configuration Methods Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndexBuilder.html?search=u32+-%3E+bool Methods for configuring the SearchIndexBuilder instance. ```APIDOC ## pub const fn max_autocomplete_options(self, maximum_autocomplete_options: usize) -> Self ### Description Sets the maximum number of auto-complete options to return. This setting can be overridden by specific function arguments. ### Default 5 ## pub const fn max_search_results(self, maximum_search_results: usize) -> Self ### Description Sets the maximum number of search results to return. This setting can be overridden by specific function arguments. ### Default 100 ## pub const fn max_keys_per_keyword(self, maximum_keys_per_keyword: usize) -> Self ### Description Limits the number of keys that may be attached to a keyword to prevent performance degradation. ### Default 40,960 ## pub fn dump_keyword(self, dump_keyword: Option) -> Self ### Description Sets a special keyword that will return or “dump” all keys in the search index, useful for modules like Select2. ### Default Some("\0".to_string()) ``` -------------------------------- ### Index a Collection Source: https://docs.rs/indicium/0.6.10/indicium/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Populate a SearchIndex from existing collections. ```rust use indicium::simple::SearchIndex; let my_vec: Vec = Vec::new(); // In the case of a `Vec` collection, we use the index as our key. A // `Vec` index is a `usize` type. Therefore we will instantiate // `SearchIndex` as `SearchIndex`. let mut search_index: SearchIndex = SearchIndex::default(); my_vec .iter() .enumerate() .for_each(|(index, element)| search_index.insert(&index, element) ); ``` ```rust use std::collections::HashMap; use indicium::simple::SearchIndex; let my_hash_map: HashMap = HashMap::new(); // In the case of a `HashMap` collection, we use the hash map's key as // the `SearchIndex` key. In our hypothetical example, we will use // MyStruct's `title` as a the key which is a `String` type. Therefore // we will instantiate `HashMap` as HashMap and // `SearchIndex` as `SearchIndex`. let mut search_index: SearchIndex = SearchIndex::default(); my_hash_map .iter() .for_each(|(key, value)| search_index.insert(key, value) ); ``` -------------------------------- ### Get mutable reference to BTreeMap value Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Retrieves a mutable reference to the value associated with the provided key. ```rust use std::collections::BTreeMap; let mut map = BTreeMap::new(); map.insert(1, "a"); if let Some(x) = map.get_mut(&1) { *x = "b"; } assert_eq!(map[&1], "b"); ``` -------------------------------- ### Index a Vec collection Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Demonstrates indexing a Vec by using its usize index as the SearchIndex key. ```rust let my_vec: Vec = Vec::new(); // In the case of a `Vec` collection, we use the index as our key. A // `Vec` index is a `usize` type. Therefore we will instantiate // `SearchIndex` as `SearchIndex`. let mut search_index: SearchIndex = SearchIndex::default(); my_vec .iter() .enumerate() .for_each(|(index, element)| search_index.insert(&index, element) ); ``` -------------------------------- ### pub fn search(&'a self, string: &'a str) -> Vec<&'a K> Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=u32+-%3E+bool Performs a search on the index using the default configuration. Returns a vector of keys matching the provided string. ```APIDOC ## pub fn search(&'a self, string: &'a str) -> Vec<&'a K> ### Description Searches the index for exact keyword matches. Returns a list of keys associated with the matching records. ### Parameters - **string** (&'a str) - The search query string. ``` -------------------------------- ### SearchIndex::new Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Creates a new, empty SearchIndex instance with specified configuration parameters for search behavior, metrics, and constraints. ```APIDOC ## pub fn new ### Description Creates a new, empty `SearchIndex`. It is often more convenient to use `SearchIndex::default()` or `SearchIndexBuilder::default()`. ### Signature `pub fn new(search_type: SearchType, autocomplete_type: AutocompleteType, eddie_metric: Option, rapidfuzz_metric: Option, strsim_metric: Option, fuzzy_length: usize, fuzzy_minimum_score: f64, split_pattern: Option>, case_sensitive: bool, minimum_keyword_length: usize, maximum_keyword_length: usize, maximum_string_length: Option, exclude_keywords: Option>, maximum_autocomplete_options: usize, maximum_search_results: usize, maximum_keys_per_keyword: usize, dump_keyword: Option) -> Self` ``` -------------------------------- ### pub fn max_keys_per_keyword(&self) -> usize Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns the maximum number of keys allowed per keyword, which helps maintain performance by preventing too many records from being attached to a single keyword. ```APIDOC ## pub fn max_keys_per_keyword(&self) -> usize ### Description Returns the current setting for the maximum number of keys that may be attached to a single keyword. ### Returns - **usize** - The maximum keys per keyword limit. ``` -------------------------------- ### pub fn autocomplete_with(&self, autocomplete_type: &AutocompleteType, maximum_autocomplete_options: &usize, string: &str) -> Vec Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Returns matching autocompleted keywords with overrides for both the AutocompleteType and the maximum number of results. ```APIDOC ## pub fn autocomplete_with(&self, autocomplete_type: &AutocompleteType, maximum_autocomplete_options: &usize, string: &str) -> Vec ### Description This autocomplete method allows the caller to define an AutocompleteType and the maximum number of autocomplete options to be returned. These parameters override the index settings. ### Parameters - **autocomplete_type** (&AutocompleteType) - The autocomplete strategy to use. - **maximum_autocomplete_options** (&usize) - The maximum number of results to return. - **string** (&str) - The search string to autocomplete. ### Returns - **Vec** - A list of matching autocompleted keywords. ``` -------------------------------- ### SearchIndex::new Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Creates a new, empty SearchIndex with specified configuration parameters. ```APIDOC ## pub fn new(search_type: SearchType, autocomplete_type: AutocompleteType, eddie_metric: Option, rapidfuzz_metric: Option, strsim_metric: Option, fuzzy_length: usize, fuzzy_minimum_score: f64, split_pattern: Option>, case_sensitive: bool, minimum_keyword_length: usize, maximum_keyword_length: usize, maximum_string_length: Option, exclude_keywords: Option>, maximum_autocomplete_options: usize, maximum_search_results: usize, maximum_keys_per_keyword: usize, dump_keyword: Option) -> Self ### Description Makes a new, empty SearchIndex. It is recommended to use SearchIndex::default() or SearchIndexBuilder::default() for simpler initialization. ``` -------------------------------- ### SearchIndexBuilder Construction Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndexBuilder.html?search=u32+-%3E+bool Methods for initializing and building the SearchIndex. ```APIDOC ## pub fn build(self) -> SearchIndex ### Description Builds the SearchIndex from the settings configured in the SearchIndexBuilder. ## fn default() -> Self ### Description Initializes a new SearchIndexBuilder with default settings. ``` -------------------------------- ### pub fn dump_keyword(&self) -> Option<&str> Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the special keyword that triggers a return of all keys in the index. ```APIDOC ## pub fn dump_keyword(&self) -> Option<&str> ### Description Returns the configured dump keyword, which, when searched, returns all keys in the index. ### Returns - **Option<&str>** - The dump keyword if configured, otherwise None. ``` -------------------------------- ### Add Indicium dependency to Cargo.toml Source: https://docs.rs/indicium/0.6.10/indicium/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Include this configuration in your project's Cargo.toml file to use the indicium crate. ```toml [dependencies] indicium = "0.6" ``` -------------------------------- ### pub fn autocomplete(&self, string: &str) -> Vec Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Returns matching autocompleted keywords for the provided search string using the default AutocompleteType setting stored in the SearchIndex. ```APIDOC ## pub fn autocomplete(&self, string: &str) -> Vec ### Description Returns matching autocompleted keywords for the provided search string. This function will use the AutocompleteType setting stored in the SearchIndex. Partial keywords must be an exact match. Results are returned in lexographic order. ### Parameters - **string** (&str) - The search string to autocomplete. ### Returns - **Vec** - A list of matching autocompleted keywords. ``` -------------------------------- ### Perform Keyword Search Source: https://docs.rs/indicium/0.6.10/indicium/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Execute searches against the index to retrieve keys matching the query. ```rust let mut search_index: SearchIndex = SearchIndex::default(); search_index.insert(&0, &"Harold Godwinson"); search_index.insert(&1, &"Edgar Ætheling"); search_index.insert(&2, &"William the Conqueror"); search_index.insert(&3, &"William Rufus"); search_index.insert(&4, &"Henry Beauclerc"); let resulting_keys: Vec<&usize> = search_index.search("William"); assert_eq!(resulting_keys, vec![&2, &3]); // Demonstrating fuzzy matching: let resulting_keys: Vec<&usize> = search_index.search("Harry"); assert_eq!(resulting_keys, vec![&0]); ``` -------------------------------- ### Try to insert key-value pair Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Experimental API that returns an error if the key is already occupied. ```rust #![feature(map_try_insert)] use std::collections::BTreeMap; let mut map = BTreeMap::new(); assert_eq!(map.try_insert(37, "a").unwrap(), &"a"); let err = map.try_insert(37, "b").unwrap_err(); assert_eq!(err.entry.key(), &37); assert_eq!(err.entry.get(), &"a"); assert_eq!(err.key, 37); assert_eq!(err.value, "b"); ``` -------------------------------- ### Use upper_bound_mut with BTreeMap Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Demonstrates using upper_bound_mut with different Bound types to navigate a BTreeMap. Requires the btree_cursors feature flag. ```rust #![feature(btree_cursors)] use std::collections::BTreeMap; use std::ops::Bound; let mut map = BTreeMap::from([ (1, "a"), (2, "b"), (3, "c"), (4, "d"), ]); let mut cursor = map.upper_bound_mut(Bound::Included(&3)); assert_eq!(cursor.peek_prev(), Some((&3, &mut "c"))); assert_eq!(cursor.peek_next(), Some((&4, &mut "d"))); let mut cursor = map.upper_bound_mut(Bound::Excluded(&3)); assert_eq!(cursor.peek_prev(), Some((&2, &mut "b"))); assert_eq!(cursor.peek_next(), Some((&3, &mut "c"))); let mut cursor = map.upper_bound_mut(Bound::Unbounded); assert_eq!(cursor.peek_prev(), Some((&4, &mut "d"))); assert_eq!(cursor.peek_next(), None); ``` -------------------------------- ### pub fn search(&'a self, string: &'a str) -> Vec<&'a K> Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a search on the index using exact keyword matching. Returns a vector of keys corresponding to the search results. ```APIDOC ## pub fn search(&'a self, string: &'a str) -> Vec<&'a K> ### Description Searches the index for exact keyword matches. Returns a list of keys that can be used to retrieve full records. ### Parameters - **string** (&'a str) - The search query string. ### Returns - **Vec<&'a K>** - A vector of references to the keys found. ``` -------------------------------- ### Retrieve dump keyword Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Returns the special keyword used to retrieve all keys in the index. ```rust assert_eq!(search_index.dump_keyword(), Some("\0")); ``` -------------------------------- ### autocomplete_with Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Returns matching autocompleted keywords for the provided search string, allowing the caller to override both the AutocompleteType and the maximum number of results. ```APIDOC ## pub fn autocomplete_with(&self, autocomplete_type: &AutocompleteType, maximum_autocomplete_options: &usize, string: &str) -> Vec ### Description Allows the caller to define an AutocompleteType and the maximum number of autocomplete options to be returned, overriding index settings. ### Parameters - **autocomplete_type** (&AutocompleteType) - The autocomplete strategy to use. - **maximum_autocomplete_options** (&usize) - The maximum number of results to return. - **string** (&str) - The search string to autocomplete. ### Returns - **Vec** - A list of matching autocompleted keywords. ``` -------------------------------- ### pub fn search_with(&'a self, search_type: &SearchType, maximum_search_results: usize, string: &'a str) -> Vec<&'a K> Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a search with a specified SearchType and a limit on the number of results. ```APIDOC ## pub fn search_with(&'a self, search_type: &SearchType, maximum_search_results: usize, string: &'a str) -> Vec<&'a K> ### Description Allows the caller to define both a SearchType and a maximum result count, overriding index settings. ### Parameters - **search_type** (&SearchType) - The search logic type to apply. - **maximum_search_results** (usize) - The maximum number of results to return. - **string** (&'a str) - The search query string. ### Returns - **Vec<&'a K>** - A vector of references to the keys found. ``` -------------------------------- ### Retrieve max_keys_per_keyword setting Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Retrieves the current maximum number of keys allowed per keyword in the search index. ```rust assert_eq!(search_index.max_keys_per_keyword(), 40_960); ``` -------------------------------- ### Manipulate First Entry Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Provides an entry API for in-place manipulation of the first element. ```rust use std::collections::BTreeMap; let mut map = BTreeMap::new(); map.insert(1, "a"); map.insert(2, "b"); if let Some(mut entry) = map.first_entry() { if *entry.key() > 0 { entry.insert("first"); } } assert_eq!(*map.get(&1).unwrap(), "first"); assert_eq!(*map.get(&2).unwrap(), "b"); ``` -------------------------------- ### fn strings(&self) -> Vec Source: https://docs.rs/indicium/0.6.10/indicium/simple/trait.Indexable.html The strings method is required to be implemented for any type that needs to be indexed. It returns a Vec containing all content that should be searchable. ```APIDOC ## fn strings(&self) -> Vec ### Description Returns a vector of strings representing all fields or content of a record that should be indexed by Indicium Search. ### Signature `fn strings(&self) -> Vec` ### Usage Implement this method for your struct to specify which data fields are included in the search index. You can convert non-string types (like numbers or enums) to strings to include them. ``` -------------------------------- ### search_with Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Performs a search with a specific SearchType and a maximum result limit. ```APIDOC ## pub fn search_with(&'a self, search_type: &SearchType, maximum_search_results: usize, string: &'a str) -> Vec<&'a K> ### Description Allows the caller to define a SearchType and a maximum number of results to return, overriding index settings. ### Parameters - **search_type** (&SearchType) - The search logic type to apply. - **maximum_search_results** (usize) - The limit on the number of results returned. - **string** (&str) - The search query string. ``` -------------------------------- ### search_with Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html Performs a search with a specific SearchType and a maximum result limit. ```APIDOC ## pub fn search_with(&'a self, search_type: &SearchType, maximum_search_results: usize, string: &'a str) -> Vec<&'a K> ### Description Allows the caller to define both a SearchType and a maximum number of results to return, overriding index settings. ### Parameters - **search_type** (&SearchType) - Required - The search logic type to apply. - **maximum_search_results** (usize) - Required - The limit on the number of results returned. - **string** (&str) - Required - The search keyword string. ``` -------------------------------- ### pub fn insert(&mut self, key: &K, value: &dyn Indexable) Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Inserts a key-value pair into the search index. It is recommended to update the search index whenever the underlying collection is updated to ensure search accuracy. ```APIDOC ## pub fn insert(&mut self, key: &K, value: &dyn Indexable) ### Description Inserts a key-value pair into the search index. For accurate search results, the index should be updated whenever the collection is modified. ### Parameters - **key** (&K) - The key associated with the record. - **value** (&dyn Indexable) - The record to be indexed, which must implement the Indexable trait. ``` -------------------------------- ### Access First Entry Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Retrieves the first key-value pair or entry in the map. ```rust use std::collections::BTreeMap; let mut map = BTreeMap::new(); assert_eq!(map.first_key_value(), None); map.insert(1, "b"); map.insert(2, "a"); assert_eq!(map.first_key_value(), Some((&1, &"b"))); ``` ```rust use std::collections::BTreeMap; let mut map = BTreeMap::new(); map.insert(1, "a"); map.insert(2, "b"); if let Some(mut entry) = map.first_entry() { if *entry.key() > 0 { entry.insert("first"); } } assert_eq!(*map.get(&1).unwrap(), "first"); assert_eq!(*map.get(&2).unwrap(), "b"); ``` -------------------------------- ### autocomplete Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Returns matching autocompleted keywords for the provided search string using the default AutocompleteType setting stored in the SearchIndex. ```APIDOC ## pub fn autocomplete(&self, string: &str) -> Vec ### Description Returns matching autocompleted keywords for the provided search string. This function uses the AutocompleteType setting stored in the SearchIndex. Results are returned in lexographic order. ### Parameters - **string** (&str) - The search string to autocomplete. ### Returns - **Vec** - A list of matching autocompleted keywords. ``` -------------------------------- ### Search for keys in SearchIndex Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Performs an exact keyword match search returning keys associated with the input string. ```rust let search_results = search_index.search("last Wessex"); assert_eq!(search_results, vec![&1]); ``` -------------------------------- ### max_autocomplete_options Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndexBuilder.html Sets the maximum number of auto-complete options to return. ```APIDOC ## pub const fn max_autocomplete_options(self, maximum_autocomplete_options: usize) -> Self ### Description Sets the maximum number of auto-complete options to return. This setting can be overridden by specific function arguments. ### Parameters - **maximum_autocomplete_options** (usize) - Required - The maximum number of options to return. Default is 5. ``` -------------------------------- ### insert Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Inserts a key-value pair into the map. ```APIDOC ## pub fn insert(&mut self, key: K, value: V) -> Option ### Description Inserts a key-value pair into the map. If the map did not have this key present, None is returned. If the map did have this key present, the value is updated, and the old value is returned. ``` -------------------------------- ### Define an Indexable Struct Source: https://docs.rs/indicium/0.6.10/indicium/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Define the data structure to be indexed. ```rust struct MyStruct { title: String, year: u16, body: String, } ``` -------------------------------- ### search Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html Performs an exact-match search against the index and returns the associated keys. ```APIDOC ## pub fn search(&'a self, string: &'a str) -> Vec<&'a K> ### Description Searches the index for exact keyword matches and returns a list of keys. These keys can be used to retrieve full records from the collection. ### Parameters - **string** (&str) - Required - The search keyword string to match against the index. ``` -------------------------------- ### dump_keyword Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Retrieves the special keyword used to return all keys in the index. ```APIDOC ## pub fn dump_keyword(&self) -> Option<&str> ### Description Returns the configured dump keyword that, when searched, returns all keys in the index. Returns None if not configured. ``` -------------------------------- ### dump_keyword Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html Retrieves the special keyword used to return all keys in the index. ```APIDOC ## pub fn dump_keyword(&self) -> Option<&str> ### Description Returns the configured dump keyword that, when searched, returns all keys currently in the index. This is useful for populating UI elements like datalists. ``` -------------------------------- ### search Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Performs a search on the index using the default search type. Returns a vector of keys matching the provided string. ```APIDOC ## pub fn search(&'a self, string: &'a str) -> Vec<&'a K> ### Description Searches the index for exact keyword matches. Returns a list of keys associated with the matching records. ### Parameters - **string** (&str) - The search query string. ``` -------------------------------- ### len Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Returns the number of elements in the map. ```APIDOC pub fn len(&self) -> usize ``` -------------------------------- ### fn strings(&self) -> Vec Source: https://docs.rs/indicium/0.6.10/indicium/simple/trait.Indexable.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E The required method for the Indexable trait. It returns a vector of strings representing all content from the record that should be indexed. ```APIDOC ## fn strings(&self) -> Vec ### Description Returns a vector of strings containing all fields or data points from the record that are intended to be indexed by Indicium Search. ### Signature `fn strings(&self) -> Vec` ### Usage Implement this method for your struct to specify indexable content: ```rust impl Indexable for MyStruct { fn strings(&self) -> Vec { vec![ self.title.clone(), self.year.to_string(), self.body.clone(), ] } } ``` ``` -------------------------------- ### pub fn clear(&mut self) Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Clears the search index by removing all stored elements. ```APIDOC ## pub fn clear(&mut self) ### Description Removes all elements from the search index. ``` -------------------------------- ### Search with custom SearchType and result limit Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Overrides index settings by specifying both a SearchType and a maximum number of results. ```rust let search_results = search_index.search_with( &SearchType::And, 20, "Conqueror third" ); assert_eq!(search_results, vec![&3]); ``` -------------------------------- ### dump_keyword Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndexBuilder.html Sets the special keyword used to dump all keys in the index. ```APIDOC ## pub fn dump_keyword(self, dump_keyword: Option) -> Self ### Description Defines a special keyword that returns all keys or records in the search index, useful for modules like Select2. ### Parameters - **dump_keyword** (Option) - Required - The keyword to trigger a dump. Default is Some("\0"). ``` -------------------------------- ### Autocomplete with custom type Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Overrides the index's default AutocompleteType setting for a specific autocomplete request. ```rust let autocomplete_options = search_index.autocomplete_type(&AutocompleteType::Global, "1100 e"); assert_eq!( autocomplete_options, vec![ "1100 edgar".to_string(), "1100 edgar ætheling".to_string(), "1100 england".to_string() ] ); ``` -------------------------------- ### Implement the Indexable Trait Source: https://docs.rs/indicium/0.6.10/indicium/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implement the Indexable trait to specify which fields should be included in the search index. ```rust use indicium::simple::Indexable; impl Indexable for MyStruct { fn strings(&self) -> Vec { vec![ self.title.clone(), self.year.to_string(), self.body.clone(), ] } } ``` -------------------------------- ### Autocomplete keywords Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Retrieves matching autocompleted keywords using the index's default AutocompleteType setting. ```rust let autocomplete_options = search_index.autocomplete("Edgar last c"); assert_eq!(autocomplete_options, vec!["edgar last cerdic".to_string()]); ``` -------------------------------- ### Insert key-value pair into BTreeMap Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Adds a key-value pair, returning the old value if the key was already present. ```rust use std::collections::BTreeMap; let mut map = BTreeMap::new(); assert_eq!(map.insert(37, "a"), None); assert_eq!(map.is_empty(), false); map.insert(37, "b"); assert_eq!(map.insert(37, "c"), Some("b")); assert_eq!(map[&37], "c"); ``` -------------------------------- ### Pop First Element Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Removes and returns the first element from the map. ```rust use std::collections::BTreeMap; let mut map = BTreeMap::new(); map.insert(1, "a"); map.insert(2, "b"); while let Some((key, _val)) = map.pop_first() { assert!(map.iter().all(|(k, _v)| *k > key)); } assert!(map.is_empty()); ``` -------------------------------- ### max_keys_per_keyword Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=u32+-%3E+bool Returns the maximum number of keys allowed per keyword to maintain performance. ```APIDOC ## pub fn max_keys_per_keyword(&self) -> usize ### Description Returns the `maximum_keys_per_keyword` setting from the search index, which limits the number of keys attached to a single keyword to prevent performance degradation. ### Returns - **usize** - The current maximum keys per keyword limit. ``` -------------------------------- ### lower_bound Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns a cursor pointing at the gap before the smallest key greater than the given bound. ```APIDOC ## pub fn lower_bound(&self, bound: Bound<&Q>) -> Cursor<'_, K, V> ### Description Returns a Cursor pointing at the gap before the smallest key greater than the given bound. This is a nightly-only experimental API. ### Parameters - **bound** (Bound<&Q>) - The bound to search for (Included, Excluded, or Unbounded). ``` -------------------------------- ### fn strings(&self) -> Vec Source: https://docs.rs/indicium/0.6.10/indicium/simple/trait.Indexable.html?search= This method is required to implement the Indexable trait. It returns a Vec containing all content from the record that should be indexed by Indicium Search. ```APIDOC ## fn strings(&self) -> Vec ### Description Returns a vector of strings representing all fields of a record that are to be indexed by Indicium Search. This method must be implemented for any type intended to be searchable. ### Signature `fn strings(&self) -> Vec` ### Usage Example ```rust impl Indexable for MyStruct { fn strings(&self) -> Vec { vec![ self.title.clone(), self.year.to_string(), self.body.clone(), ] } } ``` ``` -------------------------------- ### Access First Key-Value Pair Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Retrieves the entry with the minimum key in the map. ```rust use std::collections::BTreeMap; let mut map = BTreeMap::new(); assert_eq!(map.first_key_value(), None); map.insert(1, "b"); map.insert(2, "a"); assert_eq!(map.first_key_value(), Some((&1, &"b"))); ``` -------------------------------- ### Split BTreeMap at a key Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Splits the map into two at the given key, returning a new map containing all elements from the key onwards. ```rust use std::collections::BTreeMap; let mut a = BTreeMap::new(); a.insert(1, "a"); a.insert(2, "b"); a.insert(3, "c"); a.insert(17, "d"); a.insert(41, "e"); let b = a.split_off(&3); assert_eq!(a.len(), 2); assert_eq!(b.len(), 3); assert_eq!(a[&1], "a"); assert_eq!(a[&2], "b"); assert_eq!(b[&3], "c"); assert_eq!(b[&17], "d"); assert_eq!(b[&41], "e"); ``` -------------------------------- ### retain Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Retains only the elements specified by the predicate. ```APIDOC ## pub fn retain(&mut self, f: F) ### Description Retains only the elements specified by the predicate. Removes all pairs (k, v) for which f(&k, &mut v) returns false. ``` -------------------------------- ### is_empty Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Checks if the BTreeMap contains no elements. ```APIDOC ## pub fn is_empty(&self) -> bool ### Description Returns true if the map contains no elements. ### Signature `pub fn is_empty(&self) -> bool` ``` -------------------------------- ### pub fn autocomplete_type(&self, autocomplete_type: &AutocompleteType, string: &str) -> Vec Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Returns matching autocompleted keywords while allowing the caller to override the index's AutocompleteType setting. ```APIDOC ## pub fn autocomplete_type(&self, autocomplete_type: &AutocompleteType, string: &str) -> Vec ### Description This autocomplete method allows the caller to define an AutocompleteType parameter, effectively overriding the index settings. Returns matching autocompleted keywords for the provided search string. ### Parameters - **autocomplete_type** (&AutocompleteType) - The autocomplete strategy to use. - **string** (&str) - The search string to autocomplete. ### Returns - **Vec** - A list of matching autocompleted keywords. ``` -------------------------------- ### Check for key existence in BTreeMap Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Verifies if a key exists in the map using a borrowed form. ```rust use std::collections::BTreeMap; let mut map = BTreeMap::new(); map.insert(1, "a"); assert_eq!(map.contains_key(&1), true); assert_eq!(map.contains_key(&2), false); ``` -------------------------------- ### insert Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=u32+-%3E+bool Inserts a key-value pair into the search index. It is recommended to update the index whenever the underlying collection is updated. ```APIDOC ## pub fn insert(&mut self, key: &K, value: &dyn Indexable) ### Description Inserts a key-value pair into the search index. For accurate search results, the index should be updated whenever the collection is updated. ### Parameters - **key** (&K) - The key associated with the record. - **value** (&dyn Indexable) - The value to be indexed, which must implement the Indexable trait. ``` -------------------------------- ### Autocomplete with custom type and limit Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Overrides both the AutocompleteType and the maximum number of results returned. ```rust let autocomplete_options = search_index.autocomplete_with( &AutocompleteType::Global, &5, "1100 e", ); assert_eq!( autocomplete_options, vec![ "1100 edgar".to_string(), "1100 edgar ætheling".to_string(), "1100 england".to_string() ] ); ``` -------------------------------- ### max_keys_per_keyword Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndexBuilder.html Sets the maximum number of keys allowed per keyword. ```APIDOC ## pub const fn max_keys_per_keyword(self, maximum_keys_per_keyword: usize) -> Self ### Description Limits the number of keys that may be attached to a keyword to prevent performance degradation. ### Parameters - **maximum_keys_per_keyword** (usize) - Required - The maximum number of keys per keyword. Default is 40,960. ``` -------------------------------- ### Check if BTreeMap is empty Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Use is_empty to verify if the map contains no elements. ```rust use std::collections::BTreeMap; let mut a = BTreeMap::new(); assert!(a.is_empty()); a.insert(1, "a"); assert!(!a.is_empty()); ``` -------------------------------- ### max_keys_per_keyword Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html Retrieves the current setting for the maximum number of keys that can be associated with a single keyword to maintain performance. ```APIDOC ## pub fn max_keys_per_keyword(&self) -> usize ### Description Returns the `maximum_keys_per_keyword` setting from the search index. This limit helps prevent performance degradation when too many records are attached to a single keyword. ### Returns - **usize** - The maximum number of keys allowed per keyword. ``` -------------------------------- ### get_mut Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Returns a mutable reference to the value corresponding to the key. ```APIDOC ## pub fn get_mut(&mut self, key: &Q) -> Option<&mut V> ### Description Returns a mutable reference to the value corresponding to the key. ``` -------------------------------- ### Iterate over map keys Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides an iterator over the keys of the map in sorted order. ```rust use std::collections::BTreeMap; let mut a = BTreeMap::new(); a.insert(2, "b"); a.insert(1, "a"); let keys: Vec<_> = a.keys().cloned().collect(); assert_eq!(keys, [1, 2]); ``` -------------------------------- ### split_off Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=std%3A%3Avec Splits the collection into two at the given key. Returns everything after the given key, including the key. ```APIDOC pub fn split_off(&mut self, key: &Q) -> BTreeMap where Q: Ord + ?Sized, K: Borrow + Ord, A: Clone ``` -------------------------------- ### Define SearchIndex struct Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= The core structure for the search index, generic over a key type K that implements Ord. ```rust pub struct SearchIndex { /* private fields */ } ``` -------------------------------- ### upper_bound Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Returns a cursor pointing at the gap after the greatest key smaller than the given bound. ```APIDOC ## pub fn upper_bound(&self, bound: Bound<&Q>) -> Cursor<'_, K, V> ### Description Returns a Cursor pointing at the gap after the greatest key smaller than the given bound. This is a nightly-only experimental API. ### Parameters - **bound** (Bound<&Q>) - The bound to search for (Included, Excluded, or Unbounded). ``` -------------------------------- ### SearchIndex::replace Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html Replaces or updates the value for a key-value pair in the search index. ```APIDOC ## pub fn replace(&mut self, key: &K, before: &dyn Indexable, after: &dyn Indexable) ### Description Replaces (or updates) the value for a key-value pair in the search index. Note that for the search results to be accurate, it is important to update the search index as the collection is updated. ``` -------------------------------- ### pub fn search_type(&'a self, search_type: &SearchType, string: &'a str) -> Vec<&'a K> Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Performs a search with a specified SearchType, overriding the default index settings. ```APIDOC ## pub fn search_type(&'a self, search_type: &SearchType, string: &'a str) -> Vec<&'a K> ### Description Allows the caller to define a SearchType parameter to override index settings during the search. ### Parameters - **search_type** (&SearchType) - The search logic type to apply. - **string** (&'a str) - The search query string. ### Returns - **Vec<&'a K>** - A vector of references to the keys found. ``` -------------------------------- ### Perform lower_bound search on BTreeMap Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Requires the btree_cursors feature. Returns a cursor pointing to the gap before the smallest key satisfying the bound condition. ```rust #![feature(btree_cursors)] use std::collections::BTreeMap; use std::ops::Bound; let map = BTreeMap::from([ (1, "a"), (2, "b"), (3, "c"), (4, "d"), ]); let cursor = map.lower_bound(Bound::Included(&2)); assert_eq!(cursor.peek_prev(), Some((&1, &"a"))); assert_eq!(cursor.peek_next(), Some((&2, &"b"))); let cursor = map.lower_bound(Bound::Excluded(&2)); assert_eq!(cursor.peek_prev(), Some((&2, &"b"))); assert_eq!(cursor.peek_next(), Some((&3, &"c"))); let cursor = map.lower_bound(Bound::Unbounded); assert_eq!(cursor.peek_prev(), None); assert_eq!(cursor.peek_next(), Some((&1, &"a"))); ``` -------------------------------- ### Access BTreeMap keys and values Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Iterates over keys or values of the map in sorted key order. ```rust use std::collections::BTreeMap; let mut a = BTreeMap::new(); a.insert(2, "b"); a.insert(1, "a"); let keys: Vec<_> = a.keys().cloned().collect(); assert_eq!(keys, [1, 2]); ``` ```rust use std::collections::BTreeMap; let mut a = BTreeMap::new(); a.insert(1, "hello"); a.insert(2, "goodbye"); let values: Vec<&str> = a.values().cloned().collect(); assert_eq!(values, ["hello", "goodbye"]); ``` ```rust use std::collections::BTreeMap; let mut a = BTreeMap::new(); a.insert(1, String::from("hello")); a.insert(2, String::from("goodbye")); for value in a.values_mut() { value.push_str("!"); } let values: Vec = a.values().cloned().collect(); assert_eq!(values, [String::from("hello!"), String::from("goodbye!")]); ``` -------------------------------- ### clear Source: https://docs.rs/indicium/0.6.10/indicium/simple/struct.SearchIndex.html?search= Removes all elements from the search index. ```APIDOC ## pub fn clear(&mut self) ### Description Clears the search index, removing all registered elements. ```