For one of my collections I created the following index:
createdOn: timestamp (Ascending)ordinal: number (Ascending)parent: reference (Ascending)
However, when I run a query that uses all three fields, firestore won't fetch anything and is suggesting this index instead (the last two fields are swapped):
createdOn: timestamp (Ascending)parent: reference (Ascending)ordinal: number (Ascending)
I also tried to change the order of where* and orderBy in the query but it didn't have any effect. So, now I have two indexes and don't understand why one of them isn't working and the other one is fine.
Why do I need a different index? The docs don't mention it (at least here).
The query I'm using is this one:
private val firestore = FirebaseFirestore.getInstance()
fun texts(languageId: String, storyId: String): Task<QuerySnapshot> {
return firestore
.collection("/languages/$languageId/texts")
.whereIn("createdOn", dates) // <-- List<Timestamp>
.whereEqualTo("parent", firestore.document("/languages/$languageId/stories/$storyId"))
.orderBy("ordinal", Query.Direction.ASCENDING)
.get()
}