Trait elastic_types::date::mapping::DateMapping [] [src]

pub trait DateMapping where
    Self: Default
{ type Format: DateFormat; fn boost() -> Option<f32> { ... }
fn doc_values() -> Option<bool> { ... }
fn include_in_all() -> Option<bool> { ... }
fn index() -> Option<bool> { ... }
fn store() -> Option<bool> { ... }
fn ignore_malformed() -> Option<bool> { ... }
fn null_value() -> Option<Date<Self>> { ... } }

The base requirements for mapping a date type.

Examples

Define a custom DateMapping:

Define a custom DateMapping that's valid for a single DateFormat:

#[derive(Default)]
struct MyDateMapping;
impl DateMapping for MyDateMapping {
    type Format = EpochMillis;

    //Overload the mapping functions here
    fn boost() -> Option<f32> {
        Some(1.5)
    }
}

This will produce the following mapping:

{
    "type": "date",
    "format": "epoch_millis",
    "boost": 1.5
}

Map with a generic Format

You can use a generic input parameter to make your DateMapping work for any kind of DateFormat:

#[derive(Default)]
struct MyDateMapping<F> {
    _marker: PhantomData<F>
}

impl <F> DateMapping for MyDateMapping<F> 
    where F: DateFormat
{
    type Format = F;
}

This is how DefaultDateMapping is able to support any format.

Associated Types

The date format bound to this mapping.

The value of Format::name() is what's sent to Elasticsearch as the format to use. This is also used to serialise and deserialise formatted Dates.

Provided Methods

Field-level index time boosting. Accepts a floating point number, defaults to 1.0.

Should the field be stored on disk in a column-stride fashion, so that it can later be used for sorting, aggregations, or scripting? Accepts true (default) or false.

Whether or not the field value should be included in the _all field? Accepts true or false. Defaults to false if index is set to no, or if a parent object field sets include_in_all to false. Otherwise defaults to true.

Should the field be searchable? Accepts not_analyzed (default) and no.

Whether the field value should be stored and retrievable separately from the _source field. Accepts true or false (default).

If true, malformed numbers are ignored. If false (default), malformed numbers throw an exception and reject the whole document.

Accepts a date value in one of the configured format's as the field which is substituted for any explicit null values. Defaults to null, which means the field is treated as missing.

Implementors