fillIndexes method
Fills the persistent cache indexes now instead of waiting for the background runs, for example while a loading screen is shown. Returns the number of documents indexed.
The future completes when the indexes are up to date or, when
maxDocuments is given, once that many documents were indexed (an index
that is not complete then is filled further in the background). The work
is split into runs of 100 documents; each run holds the instance for
about 5 to 20 ms on a cache without many pending writes, and the other
operations of the instance (queries, writes, snapshots) run between two
runs. Without maxDocuments the time grows with the number of cached
documents behind the indexes, about 5 to 20 seconds for 100,000.
Not in the official SDKs; specific to this package. Throws an
ArgumentError when maxDocuments is less than 1. If the instance is
terminated meanwhile, the future completes with the count so far.
Implementation
Future<int> fillIndexes({int? maxDocuments}) {
if (maxDocuments != null && maxDocuments < 1) {
throw ArgumentError.value(
maxDocuments,
'maxDocuments',
'must be at least 1',
);
}
return _client.fillIndexes(maxDocuments: maxDocuments);
}