IndexOptions
public struct IndexOptions : Encodable
Options to use when creating an index for a collection.
-
Optionally tells the server to build the index in the background and not block other tasks.
Declaration
Swift
public let background: Bool?
-
Optionally specifies the length in time, in seconds, for documents to remain in a collection.
Declaration
Swift
public let expireAfter: Int32?
-
Optionally specify a specific name for the index outside of the default generated name. If none is provided then the name is generated in the format
[field]_[direction]
.Note that if an index is created for the same key pattern with different collations, a name must be provided by the user to avoid ambiguity.
- Example: For an index of name: 1, age: -1, the generated name would be
name_1_age_-1
.
Declaration
Swift
public let name: String?
- Example: For an index of name: 1, age: -1, the generated name would be
-
Optionally tells the index to only reference documents with the specified field in the index.
Declaration
Swift
public let sparse: Bool?
-
Optionally used only in MongoDB 3.0.0 and higher. Specifies the storage engine to store the index in.
Declaration
Swift
public let storageEngine: String?
-
Optionally forces the index to be unique.
Declaration
Swift
public let unique: Bool?
-
Optionally specifies the index version number, either 0 or 1.
Declaration
Swift
public let version: Int32?
-
Optionally specifies the default language for text indexes. Is english if none is provided.
Declaration
Swift
public let defaultLanguage: String?
-
Optionally Specifies the field in the document to override the language.
Declaration
Swift
public let languageOverride: String?
-
Optionally provides the text index version number.
Declaration
Swift
public let textVersion: Int32?
-
Optionally specifies fields in the index and their corresponding weight values.
Declaration
Swift
public let weights: Document?
-
Optionally specifies the 2dsphere index version number.
Declaration
Swift
public let sphereVersion: Int32?
-
Optionally specifies the precision of the stored geo hash in the 2d index, from 1 to 32.
Declaration
Swift
public let bits: Int32?
-
Optionally sets the maximum boundary for latitude and longitude in the 2d index.
Declaration
Swift
public let max: Double?
-
Optionally sets the minimum boundary for latitude and longitude in the index in a 2d index.
Declaration
Swift
public let min: Double?
-
Optionally specifies the number of units within which to group the location values in a geo haystack index.
Declaration
Swift
public let bucketSize: Int32?
-
Optionally specifies a filter for use in a partial index. Only documents that match the filter expression are included in the index.
Declaration
Swift
public let partialFilterExpression: Document?
-
Optionally specifies a collation to use for the index in MongoDB 3.4 and higher. If not specified, no collation is sent and the default collation of the collection server-side is used.
Declaration
Swift
public let collation: Document?
-
init(background:expireAfter:name:sparse:storageEngine:unique:version:defaultLanguage:languageOverride:textVersion:weights:sphereVersion:bits:max:min:bucketSize:partialFilterExpression:collation:)
Convenience initializer allowing any/all parameters to be omitted.
Declaration
Swift
public init(background: Bool? = nil, expireAfter: Int32? = nil, name: String? = nil, sparse: Bool? = nil, storageEngine: String? = nil, unique: Bool? = nil, version: Int32? = nil, defaultLanguage: String? = nil, languageOverride: String? = nil, textVersion: Int32? = nil, weights: Document? = nil, sphereVersion: Int32? = nil, bits: Int32? = nil, max: Double? = nil, min: Double? = nil, bucketSize: Int32? = nil, partialFilterExpression: Document? = nil, collation: Document? = nil)