這是我在 Dart 中的 Firestore 查詢:
getResults(){
FirebaseFirestore.instance.collection('items').where("itemModel", isGreaterThanOrEqualTo: _searchQueryController.text.trim())
.where("status", isEqualTo: "approved")
.get()
.then((results){
setState(() {
items = results;
});
});
}
但它區分大小寫。例如,如果我有一個itemModel被叫的"Checkboard",如果我搜索"checkboard"(用小寫的“c”),它就不會出現。如何在不修改 Firestore 資料庫中存盤的資料的情況下使其不區分大小寫?這是我的 Firestore 資料庫的圖片供參考:
Picture of Firestore Database
uj5u.com熱心網友回復:
Firestore 中的所有查詢都區分大小寫。
如果您需要不區分大小寫的機制,您需要撰寫一個單獨的欄位,其中包含不區分大小寫的欄位版本并對其進行查詢。例如:
db.collection("items").where("itemModel", "==", "Checkboard")
db.collection("items").where("lowercaseItemModel", "==", "checkboard")
@DanMcGrath 有一個很好的答案,我建議您閱讀:
- 使用查詢的 Cloud Firestore 不區分大小寫的排序
或者來自@samthecodingman 的替代方案:
- 有沒有辦法在 Firebase firestore 中搜索而不用小寫保存另一個欄位以進行不區分大小寫的搜索?
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/341182.html
標籤:安卓 火力基地 扑 谷歌云平台 谷歌云firestore
