Closed csh0101 closed 2 years ago
Thank you for the feedback @csh0101. Sorry for the delay responding, I did not see that you had posted this until now.
When you instantiate the SearchIndexBuilder
with default settings by using SearchIndexBuilder::default()
it will automatically remove small keywords such as "a", "an", "and", "the", etc. If you add SearchIndexBuilder::default().exclude_keywords(None)
, small words will no longer be excluded from searches and autocompletion options. You can also use exclude_keywords
to add support for small word removal in other languages.
If I re-run your example with the following builder clause, it will work as expected and pass the test:
let mut search_index: SearchIndex<usize> = SearchIndexBuilder::default()
.autocomplete_type(AutocompleteType::Global)
.exclude_keywords(None)
.build();
Also note that the newest version of Indicium supports all types that implement the ToString
trait. Now you can do this:
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");
Without having to implement anything.
I hope this helps. Let me know if you have any other questions.
Closing this issue. If you have any other issues or questions, feel free to add
struct MyType<'a>(&'a str);
impl<'a> Indexable for MyType<'a> { fn strings(&self) -> Vec {
vec![self.0.to_string()]
}
}
impl From<&'static str> for MyType<'static> { fn from(input: &'static str) -> Self { MyType(input) } }
use indicium::simple::AutocompleteType; use indicium::simple::SearchIndex; use indicium::simple::SearchIndexBuilder;
fn main() { let mut search_index: SearchIndex = SearchIndexBuilder::default()
.autocomplete_type(AutocompleteType::Global)
.build();
}