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
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(self, field: &str) -> Self
pub fn add_field(self, field: &str) -> Self
Add a document field to the Index
.
If the Index
already contains a field with an identical name, adding it again is a no-op.
sourcepub fn add_fields<I>(self, fields: I) -> Selfwhere
I: IntoIterator,
I::Item: AsRef<str>,
pub fn add_fields<I>(self, fields: I) -> Selfwhere
I: IntoIterator,
I::Item: AsRef<str>,
Add the document fields to the Index
.
If the Index
already contains a field with an identical name, adding it again is a no-op.
sourcepub fn set_ref(self, ref_field: &str) -> Self
pub fn set_ref(self, ref_field: &str) -> Self
Set the key used to store the document reference field.
sourcepub fn set_pipeline(self, pipeline: Pipeline) -> Self
pub fn set_pipeline(self, pipeline: Pipeline) -> Self
Set the pipeline used by the Index
.