#[non_exhaustive]
pub struct IndexOptions {
Show 20 fields pub background: Option<bool>, pub expire_after: Option<Duration>, pub name: Option<String>, pub sparse: Option<bool>, pub storage_engine: Option<Document>, pub unique: Option<bool>, pub version: Option<IndexVersion>, pub default_language: Option<String>, pub language_override: Option<String>, pub text_index_version: Option<TextIndexVersion>, pub weights: Option<Document>, pub sphere_2d_index_version: Option<Sphere2DIndexVersion>, pub bits: Option<u32>, pub max: Option<f64>, pub min: Option<f64>, pub bucket_size: Option<u32>, pub partial_filter_expression: Option<Document>, pub collation: Option<Collation>, pub wildcard_projection: Option<Document>, pub hidden: Option<bool>,
}
Expand description

These are the valid options for specifying an IndexModel. For more information on these properties, see the documentation.

Fields (Non-exhaustive)

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
background: Option<bool>

Tells the server to build the index in the background and not block other tasks. Starting in MongoDB 4.2, this option is deprecated and ignored by the server.

expire_after: Option<Duration>

Specifies a TTL to control how long MongoDB retains documents in this collection.

See the documentation for more information on how to use this option.

name: Option<String>

Specifies a name outside the default generated name.

sparse: Option<bool>

If true, the index only references documents with the specified field. The default value is false.

See the documentation for more information on how to use this option.

storage_engine: Option<Document>

Allows users to configure the storage engine on a per-index basis when creating an index.

unique: Option<bool>

Forces the index to be unique so the collection will not accept documents where the index key value matches an existing value in the index. The default value is false.

version: Option<IndexVersion>

Specify the version number of the index. Starting in MongoDB 3.2, Version 0 indexes are not allowed.

default_language: Option<String>

For text indexes, the language that determines the list of stop words and the rules for the stemmer and tokenizer.

language_override: Option<String>

For text indexes, the name of the field, in the collection’s documents, that contains the override language for the document.

text_index_version: Option<TextIndexVersion>

The text index version number. Users can use this option to override the default version number.

weights: Option<Document>

For text indexes, a document that contains field and weight pairs.

sphere_2d_index_version: Option<Sphere2DIndexVersion>

The 2dsphere index version number. As of MongoDB 3.2, version 3 is the default. Version 2 is the default in MongoDB 2.6 and 3.0 series.

bits: Option<u32>

For 2dsphere indexes, the number of precision of the stored geohash value of the location data. The bits value ranges from 1 to 32 inclusive.

max: Option<f64>

For 2dsphere indexes, the upper inclusive boundary for the longitude and latitude values.

min: Option<f64>

For 2dsphere indexes, the lower inclusive boundary for the longitude and latitude values.

bucket_size: Option<u32>

For geoHaystack indexes, specify the number of units within which to group the location values.

partial_filter_expression: Option<Document>

If specified, the index only references documents that match the filter expression. See Partial Indexes for more information.

collation: Option<Collation>

Specifies the collation for the index.

wildcard_projection: Option<Document>

Allows users to include or exclude specific field paths from a wildcard index.

hidden: Option<bool>

A flag that determines whether the index is hidden from the query planner. A hidden index is not evaluated as part of the query plan selection.

Implementations

Create a builder for building IndexOptions. On the builder, call .background(...)(optional), .expire_after(...)(optional), .name(...)(optional), .sparse(...)(optional), .storage_engine(...)(optional), .unique(...)(optional), .version(...)(optional), .default_language(...)(optional), .language_override(...)(optional), .text_index_version(...)(optional), .weights(...)(optional), .sphere_2d_index_version(...)(optional), .bits(...)(optional), .max(...)(optional), .min(...)(optional), .bucket_size(...)(optional), .partial_filter_expression(...)(optional), .collation(...)(optional), .wildcard_projection(...)(optional), .hidden(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of IndexOptions.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.