我正在尝试根据名称搜索用户。如果名称是从第一个名称给出的,但没有在字符串上搜索第二个名称,那么它会完美搜索。例如,第一个和第二个都保存在一个由空格分隔的值中 “约翰·史密斯”。如果搜索“john”或“jo”等,它将检索记录,但如果搜索 smith,则不会检索到任何内容。 代码
var ref = firebase.database().ref().child('User').orderByChild("name").startAt(searchString).endAt(searchString + "\uf8ff");
$scope.usercollection = $firebaseArray(ref);
对于您的查询,通常您只会得到以 j、jo、joh、john 等开头的结果... startAt 方法“创建具有指定起点的查询”。所以它会查看你的 searchString 变量starts如何。
Firebse 目前没有全文搜索机制。您会在网上找到实现这种机制的几种可能性,例如:
https://firebase.googleblog.com/2014/01/queries-part-2-advanced-searches-with.html