我在使用 Firebase 查询时遇到了一些问题。我想查询对象,其中对象子值包含特定字符串。到目前为止,我有一些看起来像这样的东西:
Firebase *ref = [[Firebase alloc] initWithUrl:@"https://dinosaur-facts.firebaseio.com/dinosaurs"];
[[[[ref queryOrderedByKey] queryStartingAtValue:@"b"] queryEndingAtValue:@"b~"]
observeEventType:FEventTypeChildAdded withBlock:^(FDataSnapshot *snapshot) {
NSLog(@"%@", snapshot.key);
}];
但这仅给出起始值为“b”的对象。我想要包含字符串“b”的对象。我怎么做?
查询API中没有包含或模糊匹配方法,如果您扫描过,您可能已经猜到了the API https://www.firebase.com/docs/ios/api/ and 查询指南 https://www.firebase.com/docs/ios/guide/retrieving-data.html#section-queries.
这个话题不仅在 SO [1 https://stackoverflow.com/questions/25034860/firebase-how-to-match-opponents-in-a-game/25039133#25039133] [2 https://stackoverflow.com/questions/22510007/firebase-get-all-data-that-contains/22522896#22522896] [3 https://stackoverflow.com/questions/10559191/firebase-and-indexing-search] [4 https://stackoverflow.com/questions/23812624/firebase-where-like-search] [5 https://stackoverflow.com/questions/22506531/how-to-perform-sql-like-operation-on-firebase/22522874#22522874],但我已经多次谈到为什么人们应该使用真正的搜索引擎 https://www.firebase.com/blog/2014-01-02-queries-part-two.html,而不是尝试这种半心半意的搜索方法。
使用 Google 搜索网站查找结果通常比使用内置搜索更容易,这是有原因的,这是失败的主要原因。
综上所述,由于没有内置内容,如何手动执行此操作的问题的答案是设置一个服务器端进程,将数据加载/流式传输到内存中并手动搜索内容,最好有某种缓存。
但老实说,ElasticSearch 更快、更简单,而且效率更高。由于这是一个很大的话题,我将让您继续阅读关于这个主题的博客文章 https://www.firebase.com/blog/2014-01-02-queries-part-two.html.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)