相关疑难解决方法(0)

Google Firestore:查询属性值的子字符串(文本搜索)

我想添加一个简单的搜索字段,想使用类似的东西

collectionRef.where('name', 'contains', 'searchTerm')

我尝试过使用where('name', '==', '%searchTerm%'),但它没有返回任何东西.

firebase google-cloud-firestore

78
推荐指数
15
解决办法
3万
查看次数

使用查询的Cloud Firestore案例不敏感排序

我尝试使用OrderBy从Cloud Firestore读取已排序的数据.Firestore按以下顺序返回数据:

AAA
BBB
aaa
bbb

现在,我想要的是以下内容:

AAA
aaa
BBB
bbb

我希望这个结果只使用OrderBy而不是手工排序.
有没有办法在Firestore中这样排序?


请为我提供一个解决方案.

提前致谢.

javascript firebase google-cloud-firestore

15
推荐指数
1
解决办法
4367
查看次数

SELECT 哪个文档字段包含 Firestore 中的字符串?

如何在 Firestore 中选择字段值包含 'pp' 的文档;如何像whereContains("title","pp")firestore 中一样添加选项?firestore 添加了多个 where 原因,但我们还需要“包含”来改进搜索。是否有任何替代方法可用或 firestore 开发人员忽略它?

FirebaseFirestore db2 = FirebaseFirestore.getInstance();
            db2.collection("products")
                    .whereEqualTo("cat","fruits")
                    .whereEqualTo("subcat","apple")
                    .whereEqualTo("blocked",false)
                    .whereContains("title","pp")
                    .get()


                    .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
                        @Override
                        public void onComplete(@NonNull Task<QuerySnapshot> task) {
                            if (task.isSuccessful()) {
                                for(int i=0;i<task.getResult().size();i++){
                                    Product product=task.getResult().getDocuments().get(i).toObject(Product.class);
                                    Log.d(TAG+"2", product.getTitle()+"");
                                }
                                for (QueryDocumentSnapshot document : task.getResult()) {
                                  //  Log.d(TAG+"2", document.getId() + " => " + document.getData());

                                }
                            } else {
                                Log.w(TAG+"2", "Error getting documents.", task.getException());
                            }
                        }
                    });
Run Code Online (Sandbox Code Playgroud)

android firebase google-cloud-firestore

1
推荐指数
1
解决办法
2126
查看次数