Firestore文档的最大字段数? [英] Maximum number of fields for a Firestore document?

查看:87
本文介绍了Firestore文档的最大字段数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我有一个products集合,我将产品存储为以下文档:

Right now I have a products collection where I store my products as documents like the following:

文档ID:

title: STRING,
price: NUMBER,
images: ARRAY OF OBJECTS,
userImages: ARRAY OF OBJECTS,
thumbnail: STRING,
category: STRING

注意::我的网络应用大约有1000种产品.

NOTE: My web app has approximately 1000 products.

我正在考虑在客户端进行全文搜索,同时还保存数据库读取,因此我正在考虑在Firestore上复制数据并将所有产品的部分副本保存到单个文档中以进行发送到客户端,这样我就可以实现客户端的全文本搜索.

I'm thinking about doing full text search on client side, while also saving on database reads, so I'm thinking about duplicating my data on Firestore and save a partial copy of all of my products into a single document to send that to the client so I can implement client full text search with that.

我将创建一个具有1000个字段的allProducts集合.这可能吗?

I would create the allProducts collection, with a single document with 1000 fields. Is this possible?

所有产品:集合

包含具有以下字段的单个文档:

Contains a single document with the following fields:

每个字段都将包含带有产品详细信息的MAP(对象).

Every field would contain a MAP (object) with product details.

document_1_ID: {  // Same ID as the 'products' collection
  title: STRING,
  price: NUMBER,
  category: STRING,
  thumbnail
},
document_2_ID: {
  title: STRING,
  price: NUMBER,
  category: STRING,
  thumbnail
},
// AND SO ON...

注意::我仍将保持products集合不变.

NOTE: I would still keep the products collection intact.

问题

是否可以有一个包含1000个字段的文档?限制是多少?

Is it possible to have a single document with 1000 fields? What is the limit?

我正在研究这个问题,因为自从我执行客户端全文搜索以来,每个用户都需要访问我的整个产品数据库.而且,我不希望每个用户都阅读我拥有的每个文档,因为我认为这样做的成本不会很好地扩展.

I'm looking into this, because since I'm performing client full text search, every user will need to have access to my whole database of products. And I don't want every user to read every single document that I have, because I imagine that the costs of that would not scale very well.

注意2::我知道文档的最大大小为1mb.

NOTE2: I know that the maximum size for a document is 1mb.

推荐答案

根据文档,对文档中的字段数没有规定的限制.但是,一个文档最多只能有40,000个索引条目,随着文档包含默认情况下被索引的更多字段的增加,该条目将不断增加.

According to the documentation, there is no stated limit placed on the number of fields in a document. However, a document can only have up to 40,000 index entries, which will grow as documents contain more fields that are indexed by default.

这篇关于Firestore文档的最大字段数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆