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§
source§impl 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.