Error: Firestore: Operation was rejected because the system is not in a state required for the operation`s execution.
See original GitHub issueAccording 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 operation
s 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.

Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
@agersoncgps In the error message that you are seeing, there should be a http link that allows you to add an index. Any query that you issue that uses more than one field needs a composite index, and you need to define these indices beforehand. Please take a look here: https://firebase.google.com/docs/firestore/query-data/indexing
Queries that only involve one field will work with a the built-in indices.
I just did console.log(JSON.stringify(error)) and clicked the link in Chrome. Added for me right away.