【发布时间】:2021-06-29 08:38:08
【问题描述】:
我在 firebase 中有一些文件,例如:
{name:'hasaduzzaman'}
{name:'himel'}
我有类似的 firebase 查询:
const [searchtext,setSearchText] = useState('')
let collectionRef = firestore.collection('users');
collectionRef.where('name', '==', searchText) // This is comming from the state of react hooks
我的主要观点是,如果 searchText 与用户的全名不匹配,它不会返回任何内容。有没有办法使用where键而不匹配用户的全名
【问题讨论】:
-
Firestore 无法执行全文搜索。它可以执行所谓的 prefix 搜索,通过执行以下操作返回名称 以* 某个子字符串开头的文档:
collectionRef.where('name', ">=", "him").where('name', "<", "hin")。如果您需要更精细的搜索,请考虑另一种/额外的解决方案。
标签: reactjs firebase google-cloud-firestore