---
title: "POST /v1/{+parent}/indexes"
method: POST
path: "/v1/{+parent}/indexes"
tags: ["projects"]
---

# POST /v1/{+parent}/indexes

`POST /v1/{+parent}/indexes`

Creates a composite index. This returns a google.longrunning.Operation which may be used to track the status of the creation. The metadata for the operation will be the type IndexOperationMetadata.

## Path parameters

- `parent` string, required

## Request body

- GoogleFirestoreAdminV1Index — Cloud Firestore indexes enable simple and complex queries against documents in a database.
  - `multikey` boolean — Optional. Whether the index is multikey. By default, the index is not multikey. For non-multikey indexes, none of the paths in the index definition reach or traverse an array, except via an explicit array index. For multikey indexes, at most one of the paths in the index definition reach or traverse an array, except via an explicit array index. Violations will result in errors. Note this field only applies to index with MONGODB_COMPATIBLE_API ApiScope.
  - `state` 'STATE_UNSPECIFIED' | 'CREATING' | 'READY' | 'NEEDS_REPAIR' — Output only. The serving state of the index.
  - `name` string — Output only. A server defined name for this index. The form of this name for composite indexes will be: `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}` For single field indexes, this field will be empty.
  - `apiScope` 'ANY_API' | 'DATASTORE_MODE_API' | 'MONGODB_COMPATIBLE_API' — The API scope supported by this index.
  - `fields` GoogleFirestoreAdminV1IndexField[] — The fields supported by this index. For composite indexes, this requires a minimum of 2 and a maximum of 100 fields. The last field entry is always for the field path `__name__`. If, on creation, `__name__` was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, the `__name__` will be ordered ASCENDING (unless explicitly specified). For single field indexes, this will always be exactly one entry with a field path equal to the field path of the associated field.
    - `arrayConfig` 'ARRAY_CONFIG_UNSPECIFIED' | 'CONTAINS' — Indicates that this field supports operations on `array_value`s.
    - `order` 'ORDER_UNSPECIFIED' | 'ASCENDING' | 'DESCENDING' — Indicates that this field supports ordering by the specified order or comparing using =, !=, <, <=, >, >=.
    - `searchConfig` GoogleFirestoreAdminV1SearchConfig — The configuration for how to index a field for search.
      - `textSpec` GoogleFirestoreAdminV1SearchTextSpec — The specification for how to build a text search index for a field.
        - `indexSpecs` GoogleFirestoreAdminV1SearchTextIndexSpec[] — Required. Specifications for how the field should be indexed. Repeated so that the field can be indexed in multiple ways.
          - `matchType` 'TEXT_MATCH_TYPE_UNSPECIFIED' | 'MATCH_GLOBALLY' — Required. How to match the text field value.
          - `indexType` 'TEXT_INDEX_TYPE_UNSPECIFIED' | 'TOKENIZED' — Required. How to index the text field value.
      - `geoSpec` GoogleFirestoreAdminV1SearchGeoSpec — The specification for how to build a geo search index for a field.
        - `geoJsonIndexingDisabled` boolean — Optional. Disables geoJSON indexing for the field. By default, geoJSON points are indexed.
    - `vectorConfig` GoogleFirestoreAdminV1VectorConfig — The index configuration to support vector search operations
      - `dimension` integer — Required. The vector dimension this configuration applies to. The resulting index will only include vectors of this dimension, and can be used for vector search with the same dimension.
      - `flat` GoogleFirestoreAdminV1FlatIndex — An index that stores vectors in a flat data structure, and supports exhaustive search.
    - `fieldPath` string — Can be __name__. For single field indexes, this must match the name of the field or may be omitted.
  - `unique` boolean — Optional. Whether it is an unique index. Unique index ensures all values for the indexed field(s) are unique across documents.
  - `searchIndexOptions` GoogleFirestoreAdminV1SearchIndexOptions — Options for search indexes at the definition level.
    - `textLanguageOverrideFieldPath` string — Optional. The field in the document that specifies which language to use for that specific document. For indexes with MONGODB_COMPATIBLE_API ApiScope: if unspecified, the language is taken from the "language" field if it exists or from `text_language` if it does not.
    - `textLanguage` string — Optional. The language to use for text search indexes. Used as the default language if not overridden at the document level by specifying the `text_language_override_field`. The language is specified as a BCP 47 language code. For indexes with MONGODB_COMPATIBLE_API ApiScope: If unspecified, the default language is English. For indexes with `ANY_API` ApiScope: If unspecified, the default behavior is autodetect.
  - `shardCount` integer — Optional. The number of shards for the index.
  - `queryScope` 'QUERY_SCOPE_UNSPECIFIED' | 'COLLECTION' | 'COLLECTION_GROUP' | 'COLLECTION_RECURSIVE' — Indexes with a collection query scope specified allow queries against a collection that is the child of a specific document, specified at query time, and that has the same collection ID. Indexes with a collection group query scope specified allow queries against all collections descended from a specific document, specified at query time, and that have the same collection ID as this index.
  - `density` 'DENSITY_UNSPECIFIED' | 'SPARSE_ALL' | 'SPARSE_ANY' | 'DENSE' — Immutable. The density configuration of the index.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/firestore.md) · [All operations](https://skmtc.net/google/apis/firestore/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/firestore/versions/11bc07a83431/schema)
