Indexing a previously excluded property in Google Firestore native mode vs datatstore mode

21 views Asked by At

I'm trying to understand the indexing behaviour of Google Firestore in native mode vs datastore mode, especially when an index exemption is either removed or introduced.

For datastore mode, the documentation is clear: https://cloud.google.com/datastore/docs/concepts/indexes

changing a property from indexed to excluded only affects entities subsequently written to your database. The index entries for any existing entities with that property will continue to exist until the entities are updated or deleted. To avoid unwanted results, you must purge your code of all queries that filter or sort by the (now excluded) property.

i.e. to un-index or re-index a property, my app needs to trawl through all documents and re-write them to the database.

I cannot find the same documentation for Google Firestore in native mode

it appears that, in native mode, you just need to add/remove the exemption in the console and the indexes are rebuilt including any existing records

is this correct?

1

There are 1 answers

2
Frank van Puffelen On

it appears that, in native mode, you just need to add/remove the exemption in the console and the indexes are rebuilt including any existing records

When you add an index to Firestore in native mode, all existing documents are indeed added to the index automatically. You can most easily see this in the Firestore console when you add the index, as the amount of time it takes to build the index is linear to the number of existing documents in that collection.