SuggestionTrie

A Radix trie for suggestion search, it allows searching for data indexed by a set of keywords fast.

Examples

A common usage for suggestion tries is to find data like words, documents, executables and any other data that is associated with a set of words;

Search for a word (in this example, an password) in a list with +256M entries in µs.

You can add custom data to the indexed suggestions, like file paths, dates, hashes, etc.

Usage

Cargo.toml

toml suggestion_trie = "^0.1"

Code example

```rust use suggestiontrie::{TrieRoot, TrieInputData}; use suggestiontrie::Suggestion; let mut trieroot: TrieRoot = TrieRoot::::new(5, Some(100)); // Get the data you want to insert into the trie let entries = vec![ // Use lowercase keywords and query if you want to do case insensitive searches TrieInputData { suggestion: Suggestion::new("Rat".tostring(), Some(4)), keywords: vec!["Mice".tostring(), "Rat".tostring(), "Mouse".tostring(), "Rodent".tostring()], }, TrieInputData { suggestion: Suggestion::new("Cat".tostring(), Some(8000)), keywords: vec!["Cat".tostring(), "Kitten".tostring(), "Kitty".tostring()], } ]; // Build the trie trie_root.build(&entries);

// Search and get results let results = trieroot.getsuggestions("Rodent"); assert_eq!(results.unwrap()[0].title, "Rat"); ```

Docs

check the docs here