Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/hex/src/data/deps.ts>mongo.IndexOptions

An ecosystem delivering practices, philosophy and portability.
Go to Latest
interface mongo.IndexOptions
import { type mongo } from "https://deno.land/x/hex@0.5.15/src/data/deps.ts";
const { IndexOptions } = mongo;

Properties

Specifies the index’s fields. For each field, specify a key-value pair in which the key is the name of the field to index and the value is either the index direction or index type. If specifying direction, specify 1 for ascending or -1 for descending.

name: string

A name that uniquely identifies the index.

optional
background: boolean

Optional. Deprecated in MongoDB 4.2.

optional
unique: boolean

Optional. Creates a unique index so that the collection will not accept insertion or update of documents where the index key value matches an existing value in the index. Specify true to create a unique index. The default value is false.

optional
partialFilterExpression: Document

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

optional
sparse: boolean

Optional. If true, the index only references documents with the specified field. These indexes use less space but behave differently in some situations (particularly sorts). The default value is false. See Sparse Indexes for more information.

optional
expireAfterSeconds: number

Optional. Specifies a value, in seconds, as a TTL to control how long MongoDB retains documents in this collection. See Expire Data from Collections by Setting TTL for more information on this functionality. This applies only to TTL indexes.

optional
hidden: boolean

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

optional
storageEngine: Document

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

optional
weights: Document

Optional. For text indexes, a document that contains field and weight pairs. The weight is an integer ranging from 1 to 99,999 and denotes the significance of the field relative to the other indexed fields in terms of the score. You can specify weights for some or all the indexed fields. See Control Search Results with Weights to adjust the scores. The default value is 1.

optional
default_language: string

Optional. For text indexes, the language that determines the list of stop words and the rules for the stemmer and tokenizer. See Text Search Languages for the available languages and Specify a Language for Text Index for more information and examples. The default value is english.

optional
language_override: string

Optional. For text indexes, the name of the field, in the collection’s documents, that contains the override language for the document. The default value is language. See Use any Field to Specify the Language for a Document for an example.

optional
textIndexVersion: number

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

optional
2dsphereIndexVersion: number

Optional. The 2dsphere index version number. Users can use this option to override the default version number.

optional
bits: number

Optional. For 2d indexes, the number of precision of the stored geohash value of the location data. The bits value ranges from 1 to 32 inclusive. The default value is 26.

optional
min: number

Optional. For 2d indexes, the lower inclusive boundary for the longitude and latitude values. The default value is -180.0.

optional
max: number

Optional. For 2d indexes, the upper inclusive boundary for the longitude and latitude values. The default value is 180.0.

optional
bucketSize: number

For geoHaystack indexes, specify the number of units within which to group the location values; i.e. group in the same bucket those location values that are within the specified number of units to each other. The value must be greater than 0.

optional
collation: Document

Optional. Specifies the collation for the index.

optional
wildcardProjection: Document

Allows users to include or exclude specific field paths from a wildcard index using the { "$**" : 1} key pattern. This option is only valid if creating a wildcard index on all document fields. You cannot specify this option if creating a wildcard index on a specific field path and its subfields, e.g. { "path.to.field.$**" : 1 }