Create One Rolling Index

POST /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/index

Creates an index on the cluster identified by its name in a rolling manner. Creating the index in this way allows index builds on one replica set member as a standalone at a time, starting with the secondary members. Creating indexes in this way requires at least one replica set election. To use this resource, the requesting Service Account or API Key must have the Project Data Access Admin role.

Rolling Index Builds on Replica Sets

Path parameters

  • groupId string Required

    Unique 24-hexadecimal digit string that identifies your project. Use the /groups endpoint to retrieve all projects to which the authenticated user has access.

    NOTE: Groups and projects are synonymous terms. Your group id is the same as your project id. For existing groups, your group/project id remains the same. The resource and corresponding endpoints use the term groups.

    Format should match the following pattern: ^([a-f0-9]{24})$.

  • clusterName string Required

    Human-readable label that identifies the cluster on which MongoDB Cloud creates an index.

    Format should match the following pattern: ^[a-zA-Z0-9][a-zA-Z0-9-]*$.

Query parameters

  • envelope boolean

    Flag that indicates whether Application wraps the response in an envelope JSON object. Some API clients cannot access the HTTP response headers or status code. To remediate this, set envelope=true in the query. Endpoints that return a list of results use the results object as an envelope. Application adds the status parameter to the response body.

    Default value is false.

  • pretty boolean

    Flag that indicates whether the response body should be in the prettyprint format.

    Default value is false.

    Prettyprint
application/vnd.atlas.2023-01-01+json

Body Required

Rolling index to create on the specified cluster.

  • collation object

    One or more settings that specify language-specific rules to compare strings within this index.

    Collation Options
    Hide collation attributes Show collation attributes object
    • alternate string

      Method to handle whitespace and punctuation as base characters for purposes of comparison. "non-ignorable" will evaluate Whitespace and Punctuation as Base Characters. "shifted" will not, MongoDB Cloud distinguishes these characters when "strength" > 3.

      Values are non-ignorable or shifted. Default value is non-ignorable.

    • backwards boolean

      Flag that indicates whether strings with diacritics sort from back of the string. Some French dictionary orders strings in this way. true will compare from back to front. false will compare from front to back.

      Default value is false.

    • caseFirst string

      Method to handle sort order of case differences during tertiary level comparisons. "upper" sorts Uppercase before lowercase. "lower" sorts Lowercase before uppercase. "off" is similar to "lower" with slight differences.

      Values are lower, off, or upper. Default value is off.

    • caseLevel boolean

      Flag that indicates whether to include case comparison when "strength" : 1 or "strength" : 2.

      • true - Include casing in comparison
        • Strength Level: 1 - Base characters and case.
        • Strength Level: 2 - Base characters, diacritics (and possible other secondary differences), and case.
      • false - Case is NOT included in comparison.

      Default value is false.

    • locale string Required

      International Components for Unicode (ICU) code that represents a localized language. To specify simple binary comparison, set "locale" : "simple".

      Values are af, sq, am, ar, hy, as, az, bn, be, bs, bs_Cyrl, bg, my, ca, chr, zh, zh_Hant, hr, cs, da, nl, dz, en, en_US, en_US_POSIX, eo, et, ee, fo, fil, fi_FI, fr, fr_CA, gl, ka, de, de_AT, el, gu, ha, haw, he, hi, hu, is, ig, smn, id, ga, it, ja, kl, kn, kk, km, kok, ko, ky, lk, lo, lv, li, lt, dsb, lb, mk, ms, ml, mt, mr, mn, ne, se, nb, nn, or, om, ps, fa, fa_AF, pl, pt, pa, ro, ru, sr, sr_Latn, si, sk, sl, es, sw, sv, ta, te, th, bo, to, tr, uk, hsb, ur, ug, vi, wae, cy, yi, yo, zu, or simple.

    • maxVariable string

      Field that indicates which characters can be ignored when "alternate" : "shifted"."punct" ignores both whitespace and punctuation. "space" ignores whitespace. Thishas no affect if "alternate" : "non-ignorable".

      Values are punct or space.

    • normalization boolean

      Flag that indicates whether to check if the text requires normalization and then perform it. Most text doesn't require this normalization processing.

      true will check if fully normalized and perform normalization to compare text. false will not check.

      Default value is false.

    • numericOrdering boolean

      Flag that indicates whether to compare sequences of digits as numbers or as strings. true will compare as numbers, this results in 10 > 2. false will Compare as strings. This results in "10" < "2".

      Default value is false.

    • strength integer(int32)

      Degree of comparison to perform when sorting words.

      MongoDB Cloud accepts the following numeric values that correspond to the comparison level and what that comparison method is.

      • 1 - "Primary" - Compares the base characters only, ignoring other differences such as diacritics and case.
      • 2 - "Secondary" - Compares base characters (primary) and diacritics (secondary). Primary differences take precedence over secondary differences.
      • 3 - "Tertiary" - Compares base characters (primary), diacritics (secondary), and case and variants (tertiary). Differences between base characters takes precedence over secondary differences which take precedence over tertiary differences.
      • 4 - "Quaternary" - Compares for the specific use case to consider punctuation when levels 1 through 3 ignore punctuation or for processing Japanese text.
      • 5 - "Identical" - Compares for the specific use case of tie breaker.

      Minimum value is 1, maximum value is 5. Default value is 3.

  • collection string Required

    Human-readable label of the collection for which MongoDB Cloud creates an index.

  • db string Required

    Human-readable label of the database that holds the collection on which MongoDB Cloud creates an index.

  • keys array[object]

    List that contains one or more objects that describe the parameters that you want to index.

    Key-value pair that sets the parameter to index as the key and the type of index as its value. To create a multikey index, list each parameter in its own object within this array.

    Hide keys attribute Show keys attribute object
    • * string Additional properties

      Key-value pair that sets the parameter to index as the key and the type of index as its value. To create a multikey index, list each parameter in its own object within this array.

      Index Types
  • options object

    One or more settings that determine how the MongoDB Cloud creates this MongoDB index.

    Index Options
    Hide options attributes Show options attributes object
    • 2dsphereIndexVersion integer(int32)

      Index version number applied to the 2dsphere index. MongoDB 3.2 and later use version 3. Use this option to override the default version number. This option applies to the 2dsphere index type only.

      Default value is 3.

    • background boolean

      Flag that indicates whether MongoDB should build the index in the background. This applies to MongoDB databases running feature compatibility version 4.0 or earlier. MongoDB databases running FCV 4.2 or later build indexes using an optimized build process. This process holds the exclusive lock only at the beginning and end of the build process. The rest of the build process yields to interleaving read and write operations. MongoDB databases running FCV 4.2 or later ignore this option. This option applies to all index types.

      Default value is false.

    • bits integer(int32)

      Number of precision applied to the stored geohash value of the location data. This option applies to the 2d index type only.

      Default value is 26.

    • bucketSize integer(int32)

      Number of units within which to group the location values. You could group in the same bucket those location values within the specified number of units to each other. This option applies to the geoHaystack index type only.

      MongoDB 5.0 removed geoHaystack Indexes and the geoSearch command.

    • columnstoreProjection object

      The columnstoreProjection document allows to include or exclude subschemas schema. One cannot combine inclusion and exclusion statements. Accordingly, the can be either of the following: 1 or true to include the field and recursively all fields it is a prefix of in the index 0 or false to exclude the field and recursively all fields it is a prefix of from the index.

      Hide columnstoreProjection attribute Show columnstoreProjection attribute object
      • * integer(int32) Additional properties

        The columnstoreProjection document allows to include or exclude subschemas schema. One cannot combine inclusion and exclusion statements. Accordingly, the can be either of the following: 1 or true to include the field and recursively all fields it is a prefix of in the index 0 or false to exclude the field and recursively all fields it is a prefix of from the index.

    • default_language string

      Human language that determines the list of stop words and the rules for the stemmer and tokenizer. This option accepts the supported languages using its name in lowercase english or the ISO 639-2 code. If you set this parameter to "none", then the text search uses simple tokenization with no list of stop words and no stemming. This option applies to the text index type only.

      Default value is english.

    • expireAfterSeconds integer(int32)

      Number of seconds that MongoDB retains documents in a Time To Live (TTL) index.

    • hidden boolean

      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.

      Default value is false.

    • language_override string

      Human-readable label that identifies the document parameter that contains the override language for the document. This option applies to the text index type only.

      Default value is language.

    • max integer(int32)

      Upper inclusive boundary to limit the longitude and latitude values. This option applies to the 2d index type only.

      Default value is 180.

    • min integer(int32)

      Lower inclusive boundary to limit the longitude and latitude values. This option applies to the 2d index type only.

      Default value is -180.

    • name string

      Human-readable label that identifies this index. This option applies to all index types.

    • partialFilterExpression object

      Rules that limit the documents that the index references to a filter expression. All MongoDB index types accept a partialFilterExpression option. partialFilterExpression can include following expressions:

      • equality ("parameter" : "value" or using the $eq operator)
      • "$exists": true , maximum: $gt, $gte, $lt, $lte comparisons
      • $type
      • $and (top-level only) This option applies to all index types.
      Hide partialFilterExpression attribute Show partialFilterExpression attribute object
      • * object Additional properties

        Rules that limit the documents that the index references to a filter expression. All MongoDB index types accept a partialFilterExpression option. partialFilterExpression can include following expressions:

        • equality ("parameter" : "value" or using the $eq operator)
        • "$exists": true , maximum: $gt, $gte, $lt, $lte comparisons
        • $type
        • $and (top-level only) This option applies to all index types.
    • sparse boolean

      Flag that indicates whether the index references documents that only have the specified parameter. These indexes use less space but behave differently in some situations like when sorting. The following index types default to sparse and ignore this option: 2dsphere, 2d, geoHaystack, text.

      Compound indexes that includes one or more indexes with 2dsphere keys alongside other key types, only the 2dsphere index parameters determine which documents the index references. If you run MongoDB 3.2 or later, use partial indexes. This option applies to all index types.

      Default value is false.

    • storageEngine object

      Storage engine set for the specific index. This value can be set only at creation. This option uses the following format: "storageEngine" : { "<storage-engine-name>" : "<options>" } MongoDB validates storage engine configuration options when creating indexes. To support replica sets with members with different storage engines, MongoDB logs these options to the oplog during replication. This option applies to all index types.

      MongoDB Server Storage Engines
      Hide storageEngine attribute Show storageEngine attribute object
      • * object Additional properties

        Storage engine set for the specific index. This value can be set only at creation. This option uses the following format: "storageEngine" : { "<storage-engine-name>" : "<options>" } MongoDB validates storage engine configuration options when creating indexes. To support replica sets with members with different storage engines, MongoDB logs these options to the oplog during replication. This option applies to all index types.

        MongoDB Server Storage Engines
    • textIndexVersion integer(int32)

      Version applied to this text index. MongoDB 3.2 and later use version 3. Use this option to override the default version number. This option applies to the text index type only.

      Default value is 3.

    • weights object

      Relative importance to place upon provided index parameters. This object expresses this as key/value pairs of index parameter and weight to apply to that parameter. You can specify weights for some or all the indexed parameters. The weight must be an integer between 1 and 99,999. MongoDB 5.0 and later can apply weights to text indexes only.

      Hide weights attribute Show weights attribute object
      • * object Additional properties

        Relative importance to place upon provided index parameters. This object expresses this as key/value pairs of index parameter and weight to apply to that parameter. You can specify weights for some or all the indexed parameters. The weight must be an integer between 1 and 99,999. MongoDB 5.0 and later can apply weights to text indexes only.

Responses

  • 202 application/vnd.atlas.2023-01-01+json

    Accepted

  • 400 application/json

    Bad Request.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

  • 401 application/json

    Unauthorized.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

  • 403 application/json

    Forbidden.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

  • 404 application/json

    Not Found.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

  • 500 application/json

    Internal Server Error.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

  • 429 application/json

    Too Many Requests.

    Hide response attributes Show response attributes object
    • badRequestDetail object

      Bad request detail.

      Hide badRequestDetail attribute Show badRequestDetail attribute object
      • fields array[object]

        Describes all violations in a client request.

        Hide fields attributes Show fields attributes object
        • description string Required

          A description of why the request element is bad.

        • field string Required

          A path that leads to a field in the request body.

    • detail string

      Describes the specific conditions or reasons that cause each type of error.

    • error integer(int32) Required

      HTTP status code returned with this error.

      External documentation
    • errorCode string Required

      Application error code returned with this error.

    • parameters array[object]

      Parameters used to give more information about the error.

    • reason string

      Application error message returned with this error.

POST /api/atlas/v2/groups/{groupId}/clusters/{clusterName}/index
curl \
 --request POST 'https://cloud.mongodb.com/api/atlas/v2/groups/32b6e34b3d91647abb20e7b8/clusters/{clusterName}/index' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/vnd.atlas.2023-01-01+json"
2dspere Index
{
  "db": "sample_airbnb",
  "keys": [
    {
      "property_type": "1"
    }
  ],
  "options": {
    "name": "PartialIndexTest",
    "partialFilterExpression": {
      "limit": {
        "$gt": 900
      }
    }
  },
  "collation": {
    "locale": "af",
    "strength": 3,
    "alternate": "non-ignorable",
    "backwards": false,
    "caseFirst": "lower",
    "caseLevel": false,
    "maxVariable": "punct",
    "normalization": false,
    "numericOrdering": false
  },
  "collection": "accounts"
}
Sparse Index
{
  "db": "sample_airbnb",
  "keys": [
    {
      "test_field": "1"
    }
  ],
  "options": {
    "name": "SparseIndexTest",
    "sparse": true
  },
  "collation": {
    "locale": "af",
    "strength": 3,
    "alternate": "non-ignorable",
    "backwards": false,
    "caseFirst": "lower",
    "caseLevel": false,
    "maxVariable": "punct",
    "normalization": false,
    "numericOrdering": false
  },
  "collection": "accounts"
}
Partial Index
{
  "db": "sample_airbnb",
  "keys": [
    {
      "property_type": "1"
    }
  ],
  "options": {
    "name": "PartialIndexTest",
    "partialFilterExpression": {
      "limit": {
        "$gt": 900
      }
    }
  },
  "collation": {
    "locale": "af",
    "strength": 3,
    "alternate": "non-ignorable",
    "backwards": false,
    "caseFirst": "lower",
    "caseLevel": false,
    "maxVariable": "punct",
    "normalization": false,
    "numericOrdering": false
  },
  "collection": "accounts"
}
Response examples (400)
{
  "error": 400,
  "detail": "(This is just an example, the exception may not be related to this endpoint) No provider AWS exists.",
  "reason": "Bad Request",
  "errorCode": "VALIDATION_ERROR"
}
Response examples (401)
{
  "error": 401,
  "detail": "(This is just an example, the exception may not be related to this endpoint)",
  "reason": "Unauthorized",
  "errorCode": "NOT_ORG_GROUP_CREATOR"
}
Response examples (403)
{
  "error": 403,
  "detail": "(This is just an example, the exception may not be related to this endpoint)",
  "reason": "Forbidden",
  "errorCode": "CANNOT_CHANGE_GROUP_NAME"
}
Response examples (404)
{
  "error": 404,
  "detail": "(This is just an example, the exception may not be related to this endpoint) Cannot find resource AWS",
  "reason": "Not Found",
  "errorCode": "RESOURCE_NOT_FOUND"
}
Response examples (500)
{
  "error": 500,
  "detail": "(This is just an example, the exception may not be related to this endpoint)",
  "reason": "Internal Server Error",
  "errorCode": "UNEXPECTED_ERROR"
}
Response examples (429)
{
  "error": 429,
  "detail": "(This is just an example, the exception may not be related to this endpoint)",
  "reason": "Too Many Requests",
  "errorCode": "RATE_LIMITED"
}