Dmitriy  Blokhin
Dmitriy Blokhin

Reputation: 638

Firestore asks me create the index that is already exist

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

Answers (1)

Gast&#243;n Saill&#233;n
Gast&#243;n Saill&#233;n

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

Related Questions