pub struct FieldMapping {
pub name: String,
pub field_type: FieldType,
pub stored: bool,
pub indexed: bool,
pub doc_values: bool,
pub norms: bool,
pub analyzer: Option<String>,
pub search_analyzer: Option<String>,
pub parent_field: Option<String>,
pub copy_to: Vec<String>,
}Expand description
A single field’s mapping: its name, type, and indexing flags.
Flags control which index structures are built for this field:
stored: include in the document store (retrievable via_source)indexed: add to the inverted index (searchable)doc_values: create columnar storage (sortable, aggregatable)norms: store field norms for [[best-matching-25|BM25]] scoring
See [[architecture-api-surface#Schema Definition]] and [[architecture-indexing-pipeline]].
Fields§
§name: StringField name as it appears in documents.
field_type: FieldTypeData type.
stored: boolWhether to include this field’s value in the document store.
indexed: boolWhether to add this field to the inverted index for search.
doc_values: boolWhether to create columnar (doc_values) storage for sorting and aggregations.
norms: boolWhether to store field length norms for BM25 scoring.
Only meaningful for Text fields.
analyzer: Option<String>Analyzer name for Text fields. None uses the default analyzer.
search_analyzer: Option<String>Search-time analyzer name. If set, queries against this field use this
analyzer instead of analyzer. See [[feature-analysis-pipeline]].
parent_field: Option<String>If this is a multi-field sub-field, the name of the parent field.
The parent’s source value is routed to this sub-field during indexing.
None for top-level fields. See [[feature-mapping-multi-fields]].
copy_to: Vec<String>Copy this field’s value to target fields at index time. See [[feature-mapping-copy-to]].
Implementations§
Source§impl FieldMapping
impl FieldMapping
Sourcepub fn new(name: impl Into<String>, field_type: FieldType) -> Self
pub fn new(name: impl Into<String>, field_type: FieldType) -> Self
Create a mapping with sensible defaults for the given field type.
Default flags per type:
| Type | stored | indexed | doc_values | norms |
|---|---|---|---|---|
| Text | true | true | false | true |
| Keyword | true | true | true | false |
| Numeric/Boolean/Date | true | true | true | false |
Sourcepub fn doc_values(self, doc_values: bool) -> Self
pub fn doc_values(self, doc_values: bool) -> Self
Set the doc_values flag.
Sourcepub fn analyzer(self, analyzer: impl Into<String>) -> Self
pub fn analyzer(self, analyzer: impl Into<String>) -> Self
Set the analyzer name (only meaningful for Text fields).
Sourcepub fn search_analyzer(self, analyzer: impl Into<String>) -> Self
pub fn search_analyzer(self, analyzer: impl Into<String>) -> Self
Set the search-time analyzer name (only meaningful for Text fields).
See [[feature-analysis-pipeline]].
Trait Implementations§
Source§impl Clone for FieldMapping
impl Clone for FieldMapping
Source§fn clone(&self) -> FieldMapping
fn clone(&self) -> FieldMapping
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FieldMapping
impl Debug for FieldMapping
impl Eq for FieldMapping
Source§impl PartialEq for FieldMapping
impl PartialEq for FieldMapping
Source§fn eq(&self, other: &FieldMapping) -> bool
fn eq(&self, other: &FieldMapping) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for FieldMapping
Auto Trait Implementations§
impl Freeze for FieldMapping
impl RefUnwindSafe for FieldMapping
impl Send for FieldMapping
impl Sync for FieldMapping
impl Unpin for FieldMapping
impl UnsafeUnpin for FieldMapping
impl UnwindSafe for FieldMapping
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more