Firestore returning not all documents for a collection

Embid123 :

I am writing a flight planner for android. For the use of a certain REST API I need ICAO identifiers for each airport. I am trying to fetch about 14k documnets from firestore and map them to objects. Structure of my firestore: firebase structur

In the result I got exacly 7698 documents in return every time.

    val db = Firebase.firestore
    val airports = db.collection("airport")
    val myColl : ArrayList<AirportDAO> = arrayListOf()
    val start = System.currentTimeMillis()
    var end : Long

    airports.get().addOnSuccessListener {
        end = System.currentTimeMillis()
        Log.d("firebase", (end - start).toString())
        val docs = it.documents
        Log.d("size", it.size().toString())     // <-- 7698
        for (doc in docs) {
            val a = doc.toObject(AirportDAO::class.java)
            if (a != null)
                myColl.add(a)
        }

        Log.d("size", myColl.size.toString())  // <-- 7698

    }

Method get() should return all DocumentSnapshots. Are there any limitations I am not aware of?

@Edit: End of my collection. "Filtruj" means "Sort" in Polish

enter image description here

Alex Mamo :

Adding a listener on the following reference:

val airports = db.collection("airport")

It means that want to get all AirportDAO objects that exist within your airport collection. If the size of your myColl list is 7698, it means that you'll be charged with 7698 read operation when you access that collection, which in my opinion is pretty much.

I have exactly 14110 documents in my collection.

No, you don't! You have exactly 7698, that's what your code says.

If you want to filter the results, you should use Query. If you'll always need all of them, then you'll create a heavy traffic with Firestore.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=397445&siteId=1