java - 无效的查询。“in”过滤器支持值数组中最多 10 个元素
问题描述
当数组超过 10(大小)时,查询 whereIn 在 firestore 中不起作用。
无效的查询。“in”过滤器支持值数组中最多 10 个元素。
这是我的代码
Query query = postRef.whereIn("id", postIdList).orderBy("timestamp", Query.Direction.ASCENDING);
PagedList.Config config = new PagedList.Config.Builder()
.setInitialLoadSizeHint(10)
.setPageSize(3)
.build();
FirestorePagingOptions<Posts> options = new FirestorePagingOptions.Builder<Posts>()
.setLifecycleOwner(this)
.setQuery(query,config,Posts.class)
.build();
firestorePagingAdapter = new FirestorePagingAdapter<Posts, PostPagingAdapter>(options) {
@NonNull
@Override
public PostPagingAdapter onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = getLayoutInflater().inflate(R.layout.post_items,parent,false);
return new PostPagingAdapter(view);
}
@Override
protected void onBindViewHolder(@NonNull PostPagingAdapter holder, int position, @NonNull Posts model) {
holder.bind(model);
}
@Override
protected void onError(@NonNull Exception e) {
super.onError(e);
Log.e(TAG, "onError: " + e.getMessage());
}
@Override
protected void onLoadingStateChanged(@NonNull LoadingState state) {
super.onLoadingStateChanged(state);
switch (state) {
case LOADING_INITIAL:
case LOADING_MORE:
mSwipeRefreshLayout.setRefreshing(true);
break;
case LOADED:
case FINISHED:
mSwipeRefreshLayout.setRefreshing(false);
break;
case ERROR:
Toast.makeText(getApplicationContext(), "Slow internet connection", Toast.LENGTH_SHORT).show();
mSwipeRefreshLayout.setRefreshing(false);
break;
}
}
};
bookmarks_recycler_view.setAdapter(firestorePagingAdapter);
任何人请帮助在 Firestore WhereIn 查询中获取 10 多个数组字段
解决方案
如错误消息所述,您最多可以将 10 个值传递给whereIn
. 如果需要超过 10 个值,则需要执行多个查询并将结果合并到应用程序代码中。
推荐阅读
- sql - 获取第 1 天、第 7 天、第 14 天、第 21 天和第 28 天的数据
- ios - 无法离线构建依赖 pod 的 iOS 项目
- azure - 无法分配 LUIS 创作 API
- javascript - 使用属性根据选项卡 ID/href 在页面加载时激活特定选项卡
- python - CSV 'A$ 12,000.00' 从字符串与 pandas 和 read_csv 一起浮动
- javascript - JS从多个文本区域生成表格
- php - 关闭准备好的语句
- fix-protocol - 如何关闭 FXCM FIX 头寸
- swift - NSOutlineView 上的 NSTextFinder 仅显示 Find 视图
- dataset - 在 QuickSight 中创建级别明智的层次结构