Firebase“like”搜索字符串 [英] Firebase "like" search on string
问题描述
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屋!