pub struct Index { /* private fields */ }
Expand description
An elasticlunr search index.
Implementations§
Source§impl Index
impl Index
Sourcepub fn with_language<I>(lang: Box<dyn Language>, fields: I) -> Self
pub fn with_language<I>(lang: Box<dyn Language>, fields: I) -> Self
Create a new index with the provided fields for the given
Language
.
§Example
use elasticlunr::{Index, lang::English};
let mut index = Index::with_language(Box::new(English::new()), &["title", "body"]);
index.add_doc("1", &["this is a title", "this is body text"]);
§Panics
Panics if a field with the name already exists.
Sourcepub fn add_doc<I>(&mut self, doc_ref: &str, data: I)
pub fn add_doc<I>(&mut self, doc_ref: &str, data: I)
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
Auto Trait Implementations§
impl Freeze for Index
impl !RefUnwindSafe for Index
impl !Send for Index
impl !Sync for Index
impl Unpin for Index
impl !UnwindSafe for Index
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more