Struct elasticlunr::IndexBuilder
source · [−]pub struct IndexBuilder { /* private fields */ }
Expand description
A builder for an Index
with custom parameters.
Example
let mut index = IndexBuilder::new()
.save_docs(false)
.add_fields(&["title", "subtitle", "body"])
.set_ref("doc_id")
.build();
index.add_doc("doc_a", &["Chapter 1", "Welcome to Copenhagen", "..."]);
Implementations
sourceimpl IndexBuilder
impl IndexBuilder
pub fn new() -> Self
pub fn with_language(language: Box<dyn Language>) -> Self
sourcepub fn save_docs(self, save: bool) -> Self
pub fn save_docs(self, save: bool) -> Self
Set whether or not documents should be saved in the Index
’s document store.
sourcepub fn add_field_with_tokenizer(
self,
field: &str,
tokenizer: Box<dyn Fn(&str) -> Vec<String>>
) -> Self
pub fn add_field_with_tokenizer(
self,
field: &str,
tokenizer: Box<dyn Fn(&str) -> Vec<String>>
) -> Self
Add a document field to the Index
, with a custom tokenizer for that field.
Panics
Panics if a field with the name already exists.
sourcepub fn add_fields<I>(self, fields: I) -> Self where
I: IntoIterator,
I::Item: AsRef<str>,
pub fn add_fields<I>(self, fields: I) -> Self where
I: IntoIterator,
I::Item: AsRef<str>,
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for IndexBuilder
impl !Send for IndexBuilder
impl !Sync for IndexBuilder
impl Unpin for IndexBuilder
impl !UnwindSafe for IndexBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more