I want to get data from my Firestore db ordered by documentId
in descending order. When I call:
firestore.collection("users")
.orderBy(FieldPath.documentId(), Query.Direction.DESCENDING)
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {...});
I am getting error:
FAILED_PRECONDITION: The query requires an index.
With a link to Firebase console for automatic index creation. Unfortunately the automatic creation doesn't seem to work in this case. When I click on Create Index I get a message:
__name__ only indexes are not supported
For manual index creation, the doc only says about indexing by field name (not documentId
). Does anyone know how to get data from Firestore ordered by documentId
in descending order?
I know I can re-order data on client side, but ordering by id is such a natural task that I must be missing something. Thank you. I use:
compile 'com.google.firebase:firebase-firestore:11.6.0'