IndexOptions
public struct IndexOptions : Codable
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 var background: Bool?
-
Optionally specifies the precision of the stored geo hash in the 2d index, from 1 to 32.
Declaration
Swift
public var bits: Int?
-
Optionally specifies the number of units within which to group the location values in a geoHaystack index. Note: geoHaystack indexes are deprecated in MongoDB 4.4 and will be removed in a future version of the server.
Declaration
Swift
public var bucketSize: Int?
-
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 var collation: BSONDocument?
-
Optionally specifies the default language for text indexes. Is ‘english’ if none is provided.
Declaration
Swift
public var defaultLanguage: String?
-
Optionally specifies the length in time, in seconds, for documents to remain in a collection.
Declaration
Swift
public var expireAfterSeconds: Int?
-
Optionally specifies that the index should exist on the target collection but should not be used by the query planner when executing operations. This option is only supported by servers >= 4.4.
Declaration
Swift
public var hidden: Bool?
-
Optionally specifies the field in the document to override the language.
Declaration
Swift
public var languageOverride: String?
-
Optionally sets the maximum boundary for latitude and longitude in the 2d index.
Declaration
Swift
public var max: Double?
-
Optionally sets the minimum boundary for latitude and longitude in the index in a 2d index.
Declaration
Swift
public var min: Double?
-
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 var name: String?
-
Optionally specifies a filter for use in a partial index. Only documents that match the filter expression are included in the index. New in MongoDB 3.2.
Declaration
Swift
public var partialFilterExpression: BSONDocument?
-
Optionally tells the index to only reference documents with the specified field in the index.
Declaration
Swift
public var sparse: Bool?
-
Optionally specifies the 2dsphere index version number. MongoDB 2.4 can only support version 1. MongoDB 2.6 and higher may support version 1 or 2.
Declaration
Swift
public var sphereIndexVersion: Int?
-
Optionally used only in MongoDB 3.0.0 and higher. Allows users to configure the storage engine on a per-index basis when creating an index.
Declaration
Swift
public var storageEngine: BSONDocument?
-
Optionally provides the text index version number. MongoDB 2.4 can only support version 1. MongoDB 2.6 and higher may support version 1 or 2.
Declaration
Swift
public var textIndexVersion: Int?
-
Optionally forces the index to be unique.
Declaration
Swift
public var unique: Bool?
-
Optionally specifies the index version number, either 0 or 1.
Declaration
Swift
public var version: Int?
-
Optionally specifies fields in the index and their corresponding weight values.
Declaration
Swift
public var weights: BSONDocument?
-
Optionally specifies a projection document used to determine which fields are indexed by a wildcard index.
Note
Supported in MongoDB version 4.2+ only.Declaration
Swift
public var wildcardProjection: BSONDocument?
-
init(background:
bits: bucketSize: collation: defaultLanguage: hidden: expireAfterSeconds: languageOverride: max: min: name: partialFilterExpression: sparse: sphereIndexVersion: storageEngine: textIndexVersion: unique: version: weights: wildcardProjection: ) Convenience initializer allowing any/all parameters to be omitted.
Declaration
Swift
public init( background: Bool? = nil, bits: Int? = nil, bucketSize: Int? = nil, collation: BSONDocument? = nil, defaultLanguage: String? = nil, hidden: Bool? = nil, expireAfterSeconds: Int? = nil, languageOverride: String? = nil, max: Double? = nil, min: Double? = nil, name: String? = nil, partialFilterExpression: BSONDocument? = nil, sparse: Bool? = nil, sphereIndexVersion: Int? = nil, storageEngine: BSONDocument? = nil, textIndexVersion: Int? = nil, unique: Bool? = nil, version: Int? = nil, weights: BSONDocument? = nil, wildcardProjection: BSONDocument? = nil )