Firebase-js-sdk: Error: Firestore: Operation was rejected because the system is not in a state required for the operation`s execution.

Created on 20 Jan 2018  路  5Comments  路  Source: firebase/firebase-js-sdk

According to the Firebase Cloud Firestore documentation for orderBy this should work:

var facultyQuery = facultyRef.where("Middle School", "==", true).orderBy('bb_last_name', 'desc');

I also tried this to make sure it wasn't the Map data causing issues:

var facultyQuery = facultyRef.where("department", "==", "Core Teacher").orderBy('bb_last_name', 'desc');

However it produces the error:

Error: Firestore: Operation was rejected because the system is not in a state required for the operations execution. (firestore/failed-precondition).`

Both of these simpler cases work just fine:

var facultyQuery = facultyRef.orderBy('bb_last_name', 'asc');
var facultyQuery = facultyRef.where("department", "==", "Core Teacher");

But when I combine the where and the orderBy, something I have done before with other Firestore collections, it fails. The documentation also states that "...queries that only use equality clauses don't need additional indexes" so I did not think I needed one.

The link to create an index does appear if you run adb logcat if you are running on Android, but not in the Chrome error console, which is where I think it should be. Where would an iOS developer see it?

spkcb

firestore

Most helpful comment

Yes, I think the documentation did not make it entirely clear in this scenario, but you do in fact need an index. It was also confusing for me that I had to go into adb logcat to see the url for creating the index. I would have expected it in the error console.

All 5 comments

Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.

Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.

@agersoncgps - I had the same error as you. It turns out you need to set an index. But you know this already? https://github.com/invertase/react-native-firebase/issues/515

Yes, I think the documentation did not make it entirely clear in this scenario, but you do in fact need an index. It was also confusing for me that I had to go into adb logcat to see the url for creating the index. I would have expected it in the error console.

in case you can't open the generated link from the log you need to ensure the link pointed to the right account, for example:

https://console.firebase.google.com/u/0/project

make sure the number (in this case is zero) before the /project is pointing to the account that has the project

Was this page helpful?
0 / 5 - 0 ratings