[][src]Struct elasticlunr::Index

pub struct Index {
    pub fields: Vec<String>,
    pub pipeline: Pipeline,
    pub ref_field: String,
    pub version: &'static str,
    pub document_store: DocumentStore,
    // some fields omitted
}

An elasticlunr search index.

Fields

fields: Vec<String>pipeline: Pipelineref_field: Stringversion: &'static strdocument_store: DocumentStore

Methods

impl Index[src]

pub fn new<I>(fields: I) -> Self where
    I: IntoIterator,
    I::Item: AsRef<str>, 
[src]

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]

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]

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 Deserialize<'static> for Index[src]

impl Serialize for Index[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.