Firebase“like”搜索字符串

编程入门 行业动态 更新时间:2024-10-26 18:26:45
本文介绍了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中没有全文搜索机制。您可以在网上找到实现这种机制的几种可能性,例如:

firebase.googleblog/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.:

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

firebase.github.io/flashlight/

更多推荐

Firebase“like”搜索字符串

本文发布于:2023-10-28 05:32:09,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   Firebase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!