Cloud Firestore Index Definition Reference

Cloud Firestore automatically creates indexes to support the most commontypes of queries, but allows you to define custom indexes and index overrides asdescribed in theCloud Firestore guides.

You can create, modify and deploy custom indexes in the Firebase console, orusing the CLI. From the CLI, edit your index configuration file, withdefault filenamefirestore.indexes.json, and deploy using thefirebasedeploy command.

You can export indexes with the CLI usingfirebase firestore:indexes.

An index configuration file defines one object containing anindexes array and an optionalfieldOverrides array.Here's an example:

{// Required, specify compound and vector indexesindexes:[{collectionGroup:"posts",queryScope:"COLLECTION",fields:[{fieldPath:"author",arrayConfig:"CONTAINS"},{fieldPath:"timestamp",order:"DESCENDING"}]},{collectionGroup:"coffee-beans",queryScope:"COLLECTION",fields:[{fieldPath:"embedding_field",vectorConfig:{dimension:256,flat:{}}}]}],// Optional, disable indexes or enable single-field collection group indexesfieldOverrides:[{collectionGroup:"posts",fieldPath:"myBigMapField",// We want to disable indexing on our big map field, and so empty the indexes arrayindexes:[]}]}

Deploy an index configuration

Deploy your index configuration with thefirebase deploy command. If you onlywant to deploy indexes for the databases configured in your project, addthe--only firestore flag. See theoptions reference for this command.

To list deployed indexes, run thefirebase firestore:indexes command. Add the--database=<databaseID> flag to list indexes for a database other than yourproject's default database.

If you make edits to the indexes using the Firebase console, make sure you alsoupdate your local indexes file. For more on managing indexes, see theCloud Firestore guides.

JSON format

Indexes

The schema for one object in theindexes array is as follows. Optionalproperties are identified with the? character.

Note thatCloud Firestore document fields can only be indexed in one mode,thus a field object can only contain one of theorder,arrayConfig, andvectorConfig properties.

While there are fields and properties that are specific toCloud Firestoreeditions, some fields are shared as well.

Standard edition

collectionGroup:string// Labeled "Collection ID" in the Firebase consolequeryScope:string// One of "COLLECTION", "COLLECTION_GROUP"apiScope:string// "ANY_API" (the default) is the only acceptable value. Optional.density:string// "SPARSE_ALL" is the only acceptable value. Optional.fields:arrayfieldPath:stringorder?:string// One of "ASCENDING", "DESCENDING"; excludes arrayConfig and vectorConfig propertiesarrayConfig?:string// If this parameter used, must be "CONTAINS"; excludes order and vectorConfig propertiesvectorConfig?:object// Indicates that this is a vector index; excludes order and arrayConfig propertiesdimension:number// The resulting index will only include vectors of this dimensionflat:{}// Indicates the vector index is a flat index

Enterprise edition

collectionGroup:string// Labeled "Collection ID" in the Firebase consolequeryScope:string// One of "COLLECTION", "COLLECTION_GROUP"apiScope:string// "MONGODB_COMPATIBLE_API" is the only acceptable valuemultikey:boolean// Indicates if this is a multikey indexdensity:string// One of "SPARSE_ANY" or "DENSE"fields:arrayfieldPath:stringorder?:string// One of "ASCENDING", "DESCENDING"; excludes arrayConfig and vectorConfig propertiesarrayConfig?:string// If this parameter used, must be "CONTAINS"; excludes order and vectorConfig propertiesvectorConfig?:object// Indicates that this is a vector index; excludes order and arrayConfig propertiesdimension:number// The resulting index will only include vectors of this dimensionflat:{}// Indicates the vector index is a flat index

FieldOverrides

The schema for one object in thefieldOverrides array is as follows. Optionalproperties are identified with the? character.

Note thatCloud Firestore document fields can only be indexed in one mode,thus a field object cannot contain both theorder andarrayConfigproperties.

collectionGroup:string// Labeled "Collection ID" in the Firebase consolefieldPath:stringttl?:boolean// Set specified field to have TTL policy and be eligible for deletionindexes:array// Use an empty array to disable indexes on this collectionGroup + fieldPathqueryScope:string// One of "COLLECTION", "COLLECTION_GROUP"order?:string// One of "ASCENDING", "DESCENDING"; excludes arrayConfig propertyarrayConfig?:string// If this parameter used, must be "CONTAINS"; excludes order property

TTL Policy

A TTL policy can be enabled or disabled using thefieldOverrides array as follows:

// Optional, disable index single-field collection group indexesfieldOverrides:[{collectionGroup:"posts",fieldPath:"ttlField",ttl:"true",// Explicitly enable TTL on this Field.// Disable indexing so empty the indexes arrayindexes:[]}]

To keep the default indexing in the field and enable a TTL policy:

{"fieldOverrides":[{"collectionGroup":"yourCollectionGroup","fieldPath":"yourFieldPath","ttl":true,"indexes":[{"order":"ASCENDING","queryScope":"COLLECTION_GROUP"},{"order":"DESCENDING","queryScope":"COLLECTION_GROUP"},{"arrayConfig":"CONTAINS","queryScope":"COLLECTION_GROUP"}]}]}

For more information about time-to-live (TTL) policies review theofficial documentation.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-01-21 UTC.