I am trying to query the most recent children in my Firebase database and then sort that limit of recent children by a child value. I understand that the Cloud Firestore has recently been released, and that querying features continue to evolve on the Firebase Realtime Database as well.
I am using the FirebaseUI FirebaseRecyclerAdapter, and within that adapter you must enter a query. I am tweaking to add 2 queries to my RecyclerView. I am doing so as follows:
mFireAdapter = new FirebaseRecyclerAdapter<Poll, PollHolder>(
Poll.class, R.layout.latest_item, PollHolder.class,
mBaseRef.child("Polls").limitToLast(3).orderByChild("vote_count"))
Unfortunately, it is not working, as it is first ordering the whole database by the child value and then displaying those 5 values. Essentially, the result is flipped in terms of what I am seeking: I want to query by limiting to the most recent X children and THEN sort those by child value. Any ideas where I am going wrong?
Edit:
Here is my Firebase Database. Essentially, I want to limit the query to the last 3 items in that database, and then sort those 3 items by vote count. I then want them to populate the RecyclerView accordingly. I am trying to do that in the code snippet listed above, but instead of actually limiting to the last 3 items in the database it is querying the whole database.