Flutter FirebaseFirestore [cloud_firestore/failed-precondition] Issue

Viewed 233

I'm trying to execute a query that has where and orderBy in a FirebaseFirestore.instance.collection('collectionName').where('fieldName1', isEqualTo: 'value1').orderBy('fieldName1', descending:true).snapshots() statement. I've also created a composite index for both fields defined in the above statement.

Though, I'm getting this error:

[log] [cloud_firestore/failed-precondition] Operation was rejected because the system is not in a state required for the operation's execution. If performing a query, ensure it has been indexed via the Firebase console.

I'm using

firebase_core: ^1.3.0
cloud_firestore: ^2.3.0
1 Answers

I guess something might be wrong with the index. I recommend you to follow these steps:

  1. Delete the index.
  2. Run the function again. An error will be thrown.
  3. Check the logs with adb logcat.
  4. Some information will appear to create the appropriate index.
Related