Cloud Firestore not showing composite index link in the console

Viewed 187

I'm running a query which requires creation of composite index. AFAIK, there are two ways of going around it.

  1. Go to the console and manually create the index.

  2. Run the query as it is to receive an error in the console which can direct me to the Firebase console after creating the index.

But I'm not seeing any such links on the console. Here's the query:

collection.where('foo', isEqualTo: 'bar').where('baz', isLessThan: 1);

Error:

E/flutter (21010): [ERROR:flutter/lib/ui/ui_dart_state.cc(207)] Unhandled Exception: [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.
E/flutter (21010): #0      MethodChannelQuery.get (package:cloud_firestore_platform_interface/src/method_channel/method_channel_query.dart:108:7)
E/flutter (21010): <asynchronous suspension>
E/flutter (21010): #1      _JsonQuery.get (package:cloud_firestore/src/query.dart:385:9)
E/flutter (21010): <asynchronous suspension>
E/flutter (21010): #2      _FooPageState.fooMethod (package:foo_bar_baz.dart:140:27)
E/flutter (21010): <asynchronous suspension>
E/flutter (21010): 
W/Firestore(21010): (23.0.0) [WatchStream]: (602e2ef) Stream closed with status: Status{code=CANCELLED, description=Disconnecting idle stream. Timed out waiting for new targets., cause=null}.
1 Answers

Apparently Firebase has stopped returning the index creation link in client SDKs. You can still use the Admin SDK in a Cloud Function to get direct index creation link or create one yourself manually as shown:

enter image description here

Make sure you replace the collection and fields names with the original names.

Related