Struct elasticlunr::Index
[−]
[src]
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: 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"]);
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"]);
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.