FirebaseFirestoreException:UNIMPLEMENTED:不支持的FieldFilter值类型:9

时间:2018-01-24 13:35:40

标签: android firebase kotlin google-cloud-firestore

当我尝试查询数据时,我从Firebase获得了这个奇怪的例外。偶尔会发生此错误。有时它工作得很好,但有时候task.isSuccessful会返回false。 attrs是一个String数组字段,在Firestore中有2个项目。是否因为在String数组上使用whereEqualTo而发生?或者我错过了其他什么?

我正在使用this link作为指南。我真的很想知道为什么我会收到这个错误。感谢。

代码:

val queryOrderedAttributeList = attributeList
                .sortedBy { cardAttribute -> cardAttribute.name }
                .map { it.name.toLowerCase() }

        val db = FirebaseFirestore.getInstance()
        val collectionRef = db.collection("dbAllCards")
        val query = collectionRef.whereEqualTo("attrs", queryOrderedAttributeList)

query.get().addOnCompleteListener { task ->
            if (task.isSuccessful) {
                task.result.forEach { document: DocumentSnapshot? ->
                    document?.id?.let { cardList.add(it) }
                    Log.e("firebase", "${document?.id} -> ${document?.data}")
                }
            } else {
                Log.d("firebase", "Error getting documents: ", task.exception)
            }
            loadCardPathList(cardList)
        }

获取文件时出错:

com.google.firebase.firestore.FirebaseFirestoreException: UNIMPLEMENTED: Unsupported FieldFilter value type: 9
              at com.google.android.gms.internal.zzevs.zzf(Unknown Source)
              at com.google.android.gms.internal.zzenb.zza(Unknown Source)
              at com.google.android.gms.internal.zzeoa.zza(Unknown Source)
              at com.google.android.gms.internal.zzenf.zza(Unknown Source)
              at com.google.android.gms.internal.zzett.zza(Unknown Source)
              at com.google.android.gms.internal.zzett.zza(Unknown Source)
              at com.google.android.gms.internal.zzetu.zzb(Unknown Source)
              at com.google.android.gms.internal.zzeup.zzcg(Unknown Source)
              at com.google.android.gms.internal.zzeth.zzcg(Unknown Source)
              at com.google.android.gms.internal.zzevi.zzch(Unknown Source)
              at com.google.android.gms.internal.zzfmg.zzch(Unknown Source)
              at io.grpc.internal.zzac.zzdep(Unknown Source)
              at io.grpc.internal.zzaq.run(Unknown Source)
              at io.grpc.internal.zzeo.run(Unknown Source)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
              at java.util.concurrent.FutureTask.run(FutureTask.java:237)
              at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
              at com.google.android.gms.internal.zzeuu$zza.run(Unknown Source)
              at java.lang.Thread.run(Thread.java:761)
            Caused by: com.google.adroid.gms.internal.zzfk: UNIMPLEMENTED: nsupported ieldFilter value ype: 9
              at com.google.android.gms.internal.zzfof.zzddl(Unknown Source)
              at com.google.android.gms.internal.zzevs.zzf(Unknown Source) 
              at com.google.android.gms.internal.zzenb.zza(Unknown Source) 
              at com.google.android.gms.internal.zzeoa.zza(Unknown Source) 
              at com.google.android.gms.internal.zzenf.zza(Unknown Source) 
              at com.google.android.gms.internal.zzett.zza(Unknown Source) 
              at com.google.android.gms.internal.zzett.zza(Unknown Source) 
              at com.google.android.gms.internal.zzetu.zzb(Unknown Source) 
              at com.google.android.gms.internal.zzeup.zzcg(Unknown Source) 
              at com.google.android.gms.internal.zzeth.zzcg(Unknown Source) 
              at com.google.android.gms.internal.zzevi.zzch(Unknown Source) 
              at com.google.android.gms.internal.zzfmg.zzch(Unknown Source) 
              at io.grpc.internal.zzac.zzdep(Unknown Source) 
              at io.grpc.internal.zzaq.run(Unknown Source) 
              at io.grpc.internal.zzeo.run(Unknown Source) 
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428) 
              at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
              at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272) 
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
              at com.google.android.gms.internal.zzeuu$zza.run(Unknown Source) 
              at java.lang.Thread.run(Thread.java:761) 

1 个答案:

答案 0 :(得分:0)

更新:自我的原始答案以来,Cloud Firestore已添加对这类查询的支持。您不应再看到此错误消息。

您现在可以查询数组,也可以对各个数组元素进行array-contains查询。

[Firebaser here] 您已经正确诊断了这一点,您看到的错误消息是因为您正在对数组值进行whereEqualTo查询。如果将Map<>值传递给同一子句,则会收到类似的错误消息。

我们要做的第一件事是改进此错误消息,然后可能在将来添加对这些查询的支持。