【问题标题】:Firebase "like" search on string [duplicate]Firebase“喜欢”搜索字符串[重复]
【发布时间】:2017-08-14 12:48:15
【问题描述】:

我正在尝试根据 name 搜索用户。如果名称是从名字给出的,但没有在字符串上搜索第二个名字,它会完美搜索。例如,第一个和第二个都保存在一个由空格分隔的值中 “约翰·史密斯”。如果搜索“john”或“jo”等,它会检索记录,但如果它的 smith 检索,它什么也不会检索。 代码

 var ref = firebase.database().ref().child('User').orderByChild("name").startAt(searchString).endAt(searchString + "\uf8ff");
    $scope.usercollection = $firebaseArray(ref);

【问题讨论】:

标签: firebase angularfire


【解决方案1】:

对于您的查询,通常只能得到以 j、jo、joh、john 等开头的结果... startAt 方法“创建一个具有指定起点的查询”。因此,它会查看您的 searchString 变量是如何开始

Firebse 目前没有全文搜索机制。你会在网上找到几种实现这种机制的可能性,例如:

https://firebase.googleblog.com/2014/01/queries-part-2-advanced-searches-with.html

https://github.com/FirebaseExtended/flashlight

【讨论】:

    猜你喜欢
    • 2014-07-11
    • 2011-12-22
    • 1970-01-01
    • 1970-01-01
    • 2017-10-25
    • 2018-05-27
    • 2015-09-19
    • 2011-03-10
    相关资源
    最近更新 更多