【发布时间】:2023-03-14 14:00:02
【问题描述】:
我想通过 Cloud Firestore 数据库(通过文档的“NAME”字段)在我的 Flutter 应用程序上实现搜索。我遇到了下面的查询,但遗憾的是这个查询区分大小写。 如果我想搜索“Apple”,则必须输入“Apple”。输入“apple”或“Apple”不会给出任何结果。
FirebaseFirestore.instance
.collection('test')
.where(
'NAME',
isGreaterThanOrEqualTo: searchVal,
isLessThan: searchVal
.substring(0, searchVal.length - 1) +
String.fromCharCode(searchVal
.codeUnitAt(searchVal.length - 1) +
1),
)
.snapshots()
请提出任何使搜索高效且不区分大小写的方法。
【问题讨论】:
-
一种常见的做法是添加另一个字段,其值为强制为全小写的名称字段,并对输入的搜索词执行相同的操作。
标签: firebase flutter dart google-cloud-firestore cloud