firebase-kotlin-sdk icon indicating copy to clipboard operation
firebase-kotlin-sdk copied to clipboard

Query with array contains requires unexpected index creation

Open zacsst opened this issue 1 year ago • 0 comments
trafficstars

Hello

Thanks for the great library. I'm in the middle of switching from swift to KMP using firestore database. Using version 1.12

The following query that I am migrating is requiring an unexpected index. I did not expect to need a new index as I ran the same query in swift. The query works, but can someone help me understand why this is?

Any insight into why this is being required?

This is the query

feedCollection .where { USERS contains userId } .orderBy(field = LAST_POST_TIME, direction = Direction.DESCENDING) .get() .documents

The index required image

For reference: this is my query in swift code

Firestore.firestore().collection(FeedConstants.COLLECTION) .whereField(FeedConstants.USERS, arrayContains: user.id) .order(by: FeedConstants.LAST_POST_TIME, descending: true) .getDocuments{ (querySnapshot, error) in

zacsst avatar Apr 23 '24 16:04 zacsst