enableIndexAutoCreation method

Future<void> enableIndexAutoCreation()

Lets the SDK create persistent cache indexes automatically for the queries it executes against the local cache, when it believes that an index helps: the query scanned at least 100 documents and less than half of them were results.

An index is filled in the background while the app runs, by default 50 documents per minute at most (see IndexBackfillSettings), or at once with fillIndexes; queries use it as far as it is filled and scan the rest.

This feature is disabled by default. The setting is not persisted: call this every time the instance is created, or set PersistentCacheSettings.indexAutoCreation (specific to this package), which turns it on from the start of every instance.

The returned future fails with a FirestoreException with code failedPrecondition if the instance was terminated; the same holds for the other methods of this class.

Implementation

Future<void> enableIndexAutoCreation() {
  return _client.setIndexAutoCreationEnabled(enabled: true);
}