Firebase “like” search on string [duplicate]

好久不见. 提交于 2019-12-30 11:54:08

问题


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);

回答1:


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

https://github.com/FirebaseExtended/flashlight



来源:https://stackoverflow.com/questions/42951076/firebase-like-search-on-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!