Reputation: 638
I'm trying to paginate comments. The first 10 comments is loading ok, but next ones (when query contains startAfterDocument
) return error like:
Query(comments where movie_id == 1041047 order by -created, __name__) failed: Status{code=FAILED_PRECONDITION, description=The query requires an index. You can create it here: https://console.firebase.google.com/project/.......
But this index is already exist, I created it before. And if I follow the suggestion link Firebase Console tells me the same: this index is exist.
Future<List<DocumentSnapshot>> _loadPageFrom(
int index, DocumentSnapshot lastDoc) async {
Query query = Firestore.instance
.collection('comments')
.where('movie_id', isEqualTo: movieID)
.orderBy('created', descending: true);
if (lastDoc != null) query = query.startAfterDocument(lastDoc);
final snapshot = await query.limit(10).getDocuments();
return snapshot.documents;
}
What problem is here?
Upvotes: 11
Views: 4489
Reputation: 13129
If you had recently deleted your index, you will need to wait a little bit until it's deleted from your project inside GCP, after that you will be able to create it again.
Upvotes: 21