简体   繁体   English

Firestore 不返回集合的所有文档

[英]Firestore returning not all documents for a collection

I am writing a flight planner for android.我正在为 android 编写飞行计划器。 For the use of a certain REST API I need ICAO identifiers for each airport.为了使用某个 REST API,我需要每个机场的 ICAO 标识符。 I am trying to fetch about 14k documnets from firestore and map them to objects.我正在尝试从 firestore 和 map 获取大约 14k 的文档网,并将它们放到对象中。 Structure of my firestore:我的firestore的结构: 火力基地结构

In the result I got exacly 7698 documents in return every time.结果,我每次都得到准确的 7698 个文档。

    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.方法get()应该返回所有 DocumentSnapshots。 Are there any limitations I am not aware of?有什么我不知道的限制吗?

@Edit: End of my collection. @Edit:我的收藏结束。 "Filtruj" means "Sort" in Polish “Filtruj”在波兰语中的意思是“排序”

在此处输入图像描述

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.这意味着想要获取airport集合中存在的所有AirportDAO对象。 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.如果您的myColl列表的大小是7698 ,这意味着当您访问该集合时,您将被收取7698读取操作的费用,我认为这差不多。

I have exactly 14110 documents in my collection.我的收藏中正好有 14110 份文件。

No, you don't, You have exactly 7698. that's what your code says.不,你没有,你正好有 7698。这就是你的代码所说的。

If you want to filter the results, you should use Query .如果要过滤结果,则应使用Query If you'll always need all of them, then you'll create a heavy traffic with Firestore.如果您总是需要所有这些,那么您将使用 Firestore 造成大量流量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM