Struct elasticlunr::Index
source · pub struct Index {
pub fields: Vec<String>,
pub pipeline: Pipeline,
pub ref_field: String,
pub version: &'static str,
pub document_store: DocumentStore,
/* private fields */
}
Expand description
An elasticlunr search index.
Fields§
§fields: Vec<String>
§pipeline: Pipeline
§ref_field: String
§version: &'static str
§document_store: DocumentStore
Implementations§
source§impl Index
impl Index
sourcepub fn with_language<I>(lang: Language, fields: I) -> Selfwhere
I: IntoIterator,
I::Item: AsRef<str>,
pub fn with_language<I>(lang: Language, fields: I) -> Selfwhere
I: IntoIterator,
I::Item: AsRef<str>,
sourcepub fn add_doc<I>(&mut self, doc_ref: &str, data: I)where
I: IntoIterator,
I::Item: AsRef<str>,
pub fn add_doc<I>(&mut self, doc_ref: &str, data: I)where
I: IntoIterator,
I::Item: AsRef<str>,
Add the data from a document to the index.
NOTE: The elements of data
should be provided in the same order as
the fields used to create the index.
Example
let mut index = Index::new(&["title", "body"]);
index.add_doc("1", &["this is a title", "this is body text"]);
pub fn get_fields(&self) -> &[String]
sourcepub fn to_json_pretty(&self) -> String
pub fn to_json_pretty(&self) -> String
Returns the index, serialized to pretty-printed JSON.
Trait Implementations§
source§impl Deserialize<'static> for Index
impl Deserialize<'static> for Index
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'static>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'static>,
Deserialize this value from the given Serde deserializer. Read more