0

I am using FirestorePagingAdapter to display document data in RecyclerView. This is my query :

val myFollowersQuery: Query
        get() = userRelationsColRef.whereEqualTo("uid2", firebaseAuthUid)

There are three documents that have uid2 field set to some value firebaseAuthUid, and this query fetches those three documents and displays them in RecyclerView with FirestorePagingAdapter.

Each of those documents has a field "points" and I would like to order documents by that field. This is my query for that.

val myFollowersQuery: Query
        get() = userRelationsColRef.whereEqualTo("uid2", firebaseAuthUid)
                .orderBy("points", Query.Direction.ASCENDING)

This query does not return any document, those three documents with uid2 = firebaseAuthUid have field points equal to 0,10 and 100000000. I can't see any reason why this query can't order them by points field, there is no spelling error in field name, no error in field type, nothing. I first thought that maybe there is some problem with FirestorePagingAdapter and query with .orderBy but I also have in my app another fragment where I use FirestorePagingAdapter to fetch some documents and order them by timestamp field and it works as it should.

Database structure: enter image description here

Alen
  • 949
  • 3
  • 17
  • 37

1 Answers1

1

You might need to create an index for that query. If you check for errors, you will see a link that will create the index for you

Diego Garcia
  • 106
  • 1
  • 5