我在使用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”的对象 . 我怎么做?
1 回答
查询API中没有包含或模糊匹配方法,如果您已扫描the API和the guide on queries,则可能已经猜到了这些方法 .
不仅在SO [1] [2] [4] [4] [5]上讨论了这个主题,但我曾多次触及为什么应该use a real search engine,而不是尝试这种半心半意的搜索做法 .
有一个原因,谷歌网站找到结果比使用内置搜索更容易,这是失败的主要组成部分 .
综上所述,由于没有内置的包含,你手动执行此操作的问题的答案是设置服务器端进程,将数据加载/流入内存并手动搜索内容,最好是某种缓存 .
但老实说,ElasticSearch在这里更快,更简单,更高效 . 因为's a vast topic, I' ll将你推迟到blog post on this subject .