[−][src]Struct elasticlunr::Index
An elasticlunr search index.
Fields
fields: Vec<String>
pipeline: Pipeline
ref_field: String
version: &'static str
document_store: DocumentStore
Methods
impl Index
[src]
pub fn new<I>(fields: I) -> Self where
I: IntoIterator,
I::Item: AsRef<str>,
[src]
I: IntoIterator,
I::Item: AsRef<str>,
Create a new index with the provided fields.
Example
let mut index = Index::new(&["title", "body", "breadcrumbs"]); index.add_doc("1", &["How to Foo", "First, you need to `bar`.", "Chapter 1 > How to Foo"]);
Panics
Panics if multiple given fields are identical.
pub fn with_language<I>(lang: Language, fields: I) -> Self where
I: IntoIterator,
I::Item: AsRef<str>,
[src]
I: IntoIterator,
I::Item: AsRef<str>,
Create a new index with the provided fields for the given
Language
.
Example
let mut index = Index::with_language(Language::English, &["title", "body"]); index.add_doc("1", &["this is a title", "this is body text"]);
Panics
Panics if multiple given fields are identical.
pub fn add_doc<I>(&mut self, doc_ref: &str, data: I) where
I: IntoIterator,
I::Item: AsRef<str>,
[src]
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]
[src]
pub fn to_json_pretty(&self) -> String
[src]
Returns the index, serialized to pretty-printed JSON.
pub fn to_json(&self) -> String
[src]
Returns the index, serialized to JSON.
Trait Implementations
impl Debug for Index
[src]
impl Serialize for Index
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl Deserialize<'static> for Index
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'static>,
[src]
__D: Deserializer<'static>,
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,