Firebase“like”搜索字符串 [英] Firebase "like" search on string

查看:108
本文介绍了Firebase“like”搜索字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图以名字为基础搜索用户。如果名字是从第一个名字给出的,但是没有在字符串上搜索第二个名字,它会完美地搜索。第一个和第二个都保存在一个由空格分隔的值中,例如
John Smith。如果搜索john或jo等它检索记录,但如果它的史密斯没有收回。
Code

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


解决方案

您的查询是正常的,从j,jo,joh,john等开始... startAt方法用指定的起始点创建查询。因此,它看起来如何searchString变量开始



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

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



http://firebase.github。 io /手电筒/


I am trying to search the user on the basis of name . It search perfectly if the name is given from first name but didn't search on the string the second name. Where first and second both are saved in one value separated by space for example "John Smith". If search on "john" or "jo" etc it retrieve the record but if its smith it retrieve nothing. Code

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

解决方案

With your query it is normal that you only get results starting with j, jo, joh, john, etc... The startAt method "creates a Query with the specified starting point". So it looks at how your searchString variable starts.

There is no full text search mechanism in Firebse for the moment. You will find on the web several possibilities to implement such a mechanism, e.g.:

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

http://firebase.github.io/flashlight/

这篇关于Firebase“like”搜索字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆