Struct elasticlunr::Index
source · [−]pub struct Index { /* private fields */ }
Expand description
An elasticlunr search index.
Implementations
sourceimpl Index
impl Index
sourcepub fn with_language<I, L>(lang: L, fields: I) -> Self where
L: Language + 'static,
I: IntoIterator,
I::Item: AsRef<str>,
pub fn with_language<I, L>(lang: L, fields: I) -> Self where
L: Language + 'static,
I: IntoIterator,
I::Item: AsRef<str>,
Create a new index with the provided fields for the given
Language
.
Example
use elasticlunr::{Index, lang::English};
let mut index = Index::with_language(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) 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
sourceimpl Deserialize<'static> for Index
impl Deserialize<'static> for Index
sourcefn 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 !RefUnwindSafe for Index
impl !Send for Index
impl !Sync for Index
impl Unpin for Index
impl !UnwindSafe for Index
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