gpt4 book ai didi

ios - Firebase 查询 - 查找包含字符串的子项目

转载 作者:技术小花猫 更新时间:2023-10-29 10:10:02 25 4
gpt4 key购买 nike

我在使用 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,您可能已经猜到了。和 the guide on queries .

这个主题不仅在 SO [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ],但我已经多次谈到为什么应该 use a real search engine ,而不是尝试这种半心半意的搜索方法。

用 Google 搜索网站比使用内置搜索更容易找到结果是有原因的,这是失败的主要原因。

综上所述,由于没有内置包含,对于如何手动执行此操作的问题的答案是设置一个服务器端进程,将数据加载/流式传输到内存中并进行手动搜索内容,最好带有某种缓存。

但老实说,ElasticSearch 在这里更快、更简单、更高效。由于这是一个很大的话题,我会推迟你到 blog post on this subject .

关于ios - Firebase 查询 - 查找包含字符串的子项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28589092/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com