oxsearch-core 0.2.0

The core of oxsearch: the transport and endpoint traits, errors, and the common types, query DSL, retrievers and kNN generated from the Elasticsearch specification
Documentation
// Generated by `cargo run -p xtask -- generate` from elastic/elasticsearch-specification 9.5 at
// 84bf510a907bae62ffe29af35f516af287a79eab. Don't edit it: change the generator.

#[derive(Clone, Debug, PartialEq, ::serde::Serialize, ::serde::Deserialize)]
#[non_exhaustive]
pub struct ChunkRescorerChunkingSettings {
    /// The maximum size of a chunk in words.
    /// This value cannot be lower than `20` (for `sentence` strategy) or `10` (for `word` strategy).
    /// This value should not exceed the window size for the associated model.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub max_chunk_size: ::core::option::Option<i32>,
    /// The number of overlapping words for chunks.
    /// It is applicable only to a `word` chunking strategy.
    /// This value cannot be higher than half the `max_chunk_size` value.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub overlap: ::core::option::Option<i32>,
    /// The number of overlapping sentences for chunks.
    /// It is applicable only for a `sentence` chunking strategy.
    /// It can be either `1` or `0`.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub sentence_overlap: ::core::option::Option<i32>,
    /// Only applicable to the `recursive` strategy and required when using it.
    ///
    /// Sets a predefined list of separators in the saved chunking settings based on the selected text type.
    /// Values can be `markdown` or `plaintext`.
    ///
    /// Using this parameter is an alternative to manually specifying a custom `separators` list.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub separator_group: ::core::option::Option<::std::string::String>,
    /// Only applicable to the `recursive` strategy and required when using it.
    ///
    /// A list of strings used as possible split points when chunking text.
    ///
    /// Each string can be a plain string or a regular expression (regex) pattern.
    /// The system tries each separator in order to split the text, starting from the first item in the list.
    ///
    /// After splitting, it attempts to recombine smaller pieces into larger chunks that stay within
    /// the `max_chunk_size` limit, to reduce the total number of chunks generated.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub separators: ::core::option::Option<::std::vec::Vec<::std::string::String>>,
    /// The chunking strategy: `sentence`, `word`, `none` or `recursive`.
    ///
    /// * If `strategy` is set to `recursive`, you must also specify:
    ///
    /// - `max_chunk_size`
    /// - either `separators` or`separator_group`
    ///
    /// Learn more about different chunking strategies in the linked documentation.
    #[serde(skip_serializing_if = "::core::option::Option::is_none")]
    pub strategy: ::core::option::Option<::std::string::String>,
}

impl ChunkRescorerChunkingSettings {
    /// A `ChunkRescorerChunkingSettings` with its required properties set.
    pub fn new(max_chunk_size: i32) -> Self {
        Self {
            max_chunk_size: ::core::option::Option::Some(max_chunk_size.into()),
            overlap: ::core::option::Option::None,
            sentence_overlap: ::core::option::Option::None,
            separator_group: ::core::option::Option::None,
            separators: ::core::option::Option::None,
            strategy: ::core::option::Option::None,
        }
    }
}

impl ChunkRescorerChunkingSettings {
    /// Sets `overlap`.
    pub fn overlap(mut self, value: i32) -> Self {
        self.overlap = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `sentence_overlap`.
    pub fn sentence_overlap(mut self, value: i32) -> Self {
        self.sentence_overlap = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `separator_group`.
    pub fn separator_group(
        mut self,
        value: impl ::core::convert::Into<::std::string::String>,
    ) -> Self {
        self.separator_group = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `separators`.
    pub fn separators(
        mut self,
        value: impl ::core::convert::Into<::std::vec::Vec<::std::string::String>>,
    ) -> Self {
        self.separators = ::core::option::Option::Some(value.into());
        self
    }
    /// Sets `strategy`.
    pub fn strategy(mut self, value: impl ::core::convert::Into<::std::string::String>) -> Self {
        self.strategy = ::core::option::Option::Some(value.into());
        self
    }
}

#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum FieldType {
    /// `none`
    None,
    /// `geo_point`
    GeoPoint,
    /// `geo_shape`
    GeoShape,
    /// `ip`
    Ip,
    /// `binary`
    Binary,
    /// `keyword`
    Keyword,
    /// `text`
    Text,
    /// `search_as_you_type`
    SearchAsYouType,
    /// `wildcard`
    Wildcard,
    /// `date`
    Date,
    /// `date_nanos`
    DateNanos,
    /// `boolean`
    Boolean,
    /// `completion`
    Completion,
    /// `nested`
    Nested,
    /// `object`
    Object,
    /// `passthrough`
    Passthrough,
    /// `version`
    Version,
    /// `murmur3`
    Murmur3,
    /// `token_count`
    TokenCount,
    /// `percolator`
    Percolator,
    /// `integer`
    Integer,
    /// `long`
    Long,
    /// `short`
    Short,
    /// `byte`
    Byte,
    /// `float`
    Float,
    /// `half_float`
    HalfFloat,
    /// `scaled_float`
    ScaledFloat,
    /// `double`
    Double,
    /// `integer_range`
    IntegerRange,
    /// `float_range`
    FloatRange,
    /// `long_range`
    LongRange,
    /// `double_range`
    DoubleRange,
    /// `date_range`
    DateRange,
    /// `ip_range`
    IpRange,
    /// `alias`
    Alias,
    /// `join`
    Join,
    /// `rank_feature`
    RankFeature,
    /// `rank_features`
    RankFeatures,
    /// `flattened`
    Flattened,
    /// `shape`
    Shape,
    /// `histogram`
    Histogram,
    /// `constant_keyword`
    ConstantKeyword,
    /// `counted_keyword`
    CountedKeyword,
    /// `aggregate_metric_double`
    AggregateMetricDouble,
    /// `dense_vector`
    DenseVector,
    /// `semantic_text`
    SemanticText,
    /// `sparse_vector`
    SparseVector,
    /// `match_only_text`
    MatchOnlyText,
    /// `icu_collation_keyword`
    IcuCollationKeyword,
    /// A value this version of the specification doesn't list.
    Raw(::std::string::String),
}

impl FieldType {
    /// The value as Elasticsearch writes it.
    pub fn as_str(&self) -> &str {
        match self {
            Self::None => "none",
            Self::GeoPoint => "geo_point",
            Self::GeoShape => "geo_shape",
            Self::Ip => "ip",
            Self::Binary => "binary",
            Self::Keyword => "keyword",
            Self::Text => "text",
            Self::SearchAsYouType => "search_as_you_type",
            Self::Wildcard => "wildcard",
            Self::Date => "date",
            Self::DateNanos => "date_nanos",
            Self::Boolean => "boolean",
            Self::Completion => "completion",
            Self::Nested => "nested",
            Self::Object => "object",
            Self::Passthrough => "passthrough",
            Self::Version => "version",
            Self::Murmur3 => "murmur3",
            Self::TokenCount => "token_count",
            Self::Percolator => "percolator",
            Self::Integer => "integer",
            Self::Long => "long",
            Self::Short => "short",
            Self::Byte => "byte",
            Self::Float => "float",
            Self::HalfFloat => "half_float",
            Self::ScaledFloat => "scaled_float",
            Self::Double => "double",
            Self::IntegerRange => "integer_range",
            Self::FloatRange => "float_range",
            Self::LongRange => "long_range",
            Self::DoubleRange => "double_range",
            Self::DateRange => "date_range",
            Self::IpRange => "ip_range",
            Self::Alias => "alias",
            Self::Join => "join",
            Self::RankFeature => "rank_feature",
            Self::RankFeatures => "rank_features",
            Self::Flattened => "flattened",
            Self::Shape => "shape",
            Self::Histogram => "histogram",
            Self::ConstantKeyword => "constant_keyword",
            Self::CountedKeyword => "counted_keyword",
            Self::AggregateMetricDouble => "aggregate_metric_double",
            Self::DenseVector => "dense_vector",
            Self::SemanticText => "semantic_text",
            Self::SparseVector => "sparse_vector",
            Self::MatchOnlyText => "match_only_text",
            Self::IcuCollationKeyword => "icu_collation_keyword",
            Self::Raw(value) => value,
        }
    }

    /// The listed value with this name, if there is one.
    pub fn from_known(value: &str) -> ::core::option::Option<Self> {
        match value {
            "none" => ::core::option::Option::Some(Self::None),
            "geo_point" => ::core::option::Option::Some(Self::GeoPoint),
            "geo_shape" => ::core::option::Option::Some(Self::GeoShape),
            "ip" => ::core::option::Option::Some(Self::Ip),
            "binary" => ::core::option::Option::Some(Self::Binary),
            "keyword" => ::core::option::Option::Some(Self::Keyword),
            "text" => ::core::option::Option::Some(Self::Text),
            "search_as_you_type" => ::core::option::Option::Some(Self::SearchAsYouType),
            "wildcard" => ::core::option::Option::Some(Self::Wildcard),
            "date" => ::core::option::Option::Some(Self::Date),
            "date_nanos" => ::core::option::Option::Some(Self::DateNanos),
            "boolean" => ::core::option::Option::Some(Self::Boolean),
            "completion" => ::core::option::Option::Some(Self::Completion),
            "nested" => ::core::option::Option::Some(Self::Nested),
            "object" => ::core::option::Option::Some(Self::Object),
            "passthrough" => ::core::option::Option::Some(Self::Passthrough),
            "version" => ::core::option::Option::Some(Self::Version),
            "murmur3" => ::core::option::Option::Some(Self::Murmur3),
            "token_count" => ::core::option::Option::Some(Self::TokenCount),
            "percolator" => ::core::option::Option::Some(Self::Percolator),
            "integer" => ::core::option::Option::Some(Self::Integer),
            "long" => ::core::option::Option::Some(Self::Long),
            "short" => ::core::option::Option::Some(Self::Short),
            "byte" => ::core::option::Option::Some(Self::Byte),
            "float" => ::core::option::Option::Some(Self::Float),
            "half_float" => ::core::option::Option::Some(Self::HalfFloat),
            "scaled_float" => ::core::option::Option::Some(Self::ScaledFloat),
            "double" => ::core::option::Option::Some(Self::Double),
            "integer_range" => ::core::option::Option::Some(Self::IntegerRange),
            "float_range" => ::core::option::Option::Some(Self::FloatRange),
            "long_range" => ::core::option::Option::Some(Self::LongRange),
            "double_range" => ::core::option::Option::Some(Self::DoubleRange),
            "date_range" => ::core::option::Option::Some(Self::DateRange),
            "ip_range" => ::core::option::Option::Some(Self::IpRange),
            "alias" => ::core::option::Option::Some(Self::Alias),
            "join" => ::core::option::Option::Some(Self::Join),
            "rank_feature" => ::core::option::Option::Some(Self::RankFeature),
            "rank_features" => ::core::option::Option::Some(Self::RankFeatures),
            "flattened" => ::core::option::Option::Some(Self::Flattened),
            "shape" => ::core::option::Option::Some(Self::Shape),
            "histogram" => ::core::option::Option::Some(Self::Histogram),
            "constant_keyword" => ::core::option::Option::Some(Self::ConstantKeyword),
            "counted_keyword" => ::core::option::Option::Some(Self::CountedKeyword),
            "aggregate_metric_double" => ::core::option::Option::Some(Self::AggregateMetricDouble),
            "dense_vector" => ::core::option::Option::Some(Self::DenseVector),
            "semantic_text" => ::core::option::Option::Some(Self::SemanticText),
            "sparse_vector" => ::core::option::Option::Some(Self::SparseVector),
            "match_only_text" => ::core::option::Option::Some(Self::MatchOnlyText),
            "icu_collation_keyword" => ::core::option::Option::Some(Self::IcuCollationKeyword),
            _ => ::core::option::Option::None,
        }
    }
}

impl ::serde::Serialize for FieldType {
    fn serialize<S__: ::serde::Serializer>(
        &self,
        serializer: S__,
    ) -> ::core::result::Result<S__::Ok, S__::Error> {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de> ::serde::Deserialize<'de> for FieldType {
    fn deserialize<D__: ::serde::Deserializer<'de>>(
        deserializer: D__,
    ) -> ::core::result::Result<Self, D__::Error> {
        ::oxsearch_core::__private::deserialize_string_enum(deserializer, "FieldType", |value| {
            Self::from_known(value).unwrap_or_else(|| Self::Raw(value.to_owned()))
        })
    }
}