Indexes

Create a persistent index

Create a hash index.

Note:

  • In a sparse index all documents are excluded from the index that do not contain at least one of the specified index attributes (i.e. fields) or that have a value of null in any of the specified index attributes. Such documents are not indexed and are not taken into account for uniqueness checks if the unique flag is set.
  • In a non-sparse index, these documents are indexed (for non-present indexed attributes, a value of null is used) and are taken into account for uniqueness checks if the unique flag is set.
  • Unique indexes on non-shard keys are not supported in a cluster.
post/_fabric/{fabric}/_api/index/persistent

Request

Path parameters

fabricstring string required

The name of the fabric.

Query parameters

collectionstring required

The collection name.

Request body

fieldsstring[]

An array of attribute paths.

sparseboolean

True to create a sparse index.

typestring required

Must be equal to "persistent".

uniqueboolean

True to create a unique index.

deduplicateboolean

Controls whether inserting duplicate index values from the same document into a unique array index leads to a unique constraint error or not.

Example request

{
  "fields": [
    "_key"
  ],
  "sparse": true,
  "type": "persistent",
  "unique": true
}

Response

Successfully fetched existing persistent index.

codeinteger

HTTP response code.

errorboolean

Flag if there is an error in response. False for this response.

geoJsonboolean

If a geo-spatial index on a location is constructed and geoJson is true, the order within the array is longitude followed by latitude. This corresponds to the format described in http://geojson.org/geojson-spec.html#positions.

fieldsstring[]

HTTP response code.

maxNumCoverCellsinteger

The maximum number of cover cells.

worstIndexedLevelinteger

The worst indexed level.

idstring

Index identifier.

namestring

Name of the index.

selectivityEstimatenumber

The selectivity estimate of index.

sparseboolean

True if index is sparse type.

typestring

Index type.

uniqueboolean

True if index is unique.

Example response

{
  "code": 200,
  "geoJson": true,
  "fields": [
    "_key"
  ],
  "maxNumCoverCells": 8,
  "worstIndexedLevel": 4,
  "id": "61862387",
  "name": "idx_1723573111790501888",
  "selectivityEstimate": 1,
  "sparse": true,
  "type": "persistent",
  "unique": true
}

Changes

No recorded changes to this operation across all 1 revision of this API.