Firebase Cloud Firestore is new product from Firebas and is much more flexible than Firebase Realtime Databse.
It can do accomplish that query. From the docs a similar query:
citiesRef
.where("population", ">", 100000)
.orderBy("population")
.limit(2)
https://firebase.google.com/docs/firestore/query-data/order-...