如何在Firestore子文档上创建索引豁免? [英] How to create an index exemption on Firestore subdocuments?
问题描述
我们的数据库结构如下:
- 集合
foo
- 文件
- 集合
bar
- 文档包含很多字段(限制为1 MB)
- 集合
- 文件
尝试将文档写入包含34571个字段的 bar
集合中,我(从Go API中获得):
rpc错误:代码= InvalidArgument desc =实体的内置索引条目过多
好的,好的,
我尝试了其他组合,但是/
在 Collection ID
或 Field path
中均不接受,并且使用,虽然没有明确禁止,但在尝试保存豁免时会导致一般性错误.我也不确定是否允许
*
.
索引豁免基于集合ID,而不是集合路径.在这种情况下,您可以输入 bar
作为集合ID.这也意味着该豁免适用于ID为 bar
的所有集合,无论层次结构如何.
对于字段,每个豁免只能指定一个字段路径.不支持"*"全选器.有限制200个索引豁免,因此您不必无法豁免所有34571个字段.如果可能,我建议将您的字段移到地图中.然后,您可以在地图字段上禁用索引编制.
We have a database structured as follows:
- Collection
foo
- Documents
- Collection
bar
- Documents with many fields (approaching the 1 MB limit)
- Collection
- Documents
Trying to write a document to the bar
collection containing 34571 fields, I get (from the Go API):
rpc error: code = InvalidArgument desc = too many builtin index entries for entity
OK, fine, it seems I need to add an exemption:
Large array or map fields
Large array or map fields can approach the limit of 20,000 index entries per document. If you are not querying based on a large array or map field, you should exempt it from indexing.
But how? The console only lets me set a single collection name and a single field path, and slashes aren't accepted:
I tried other combinations, but /
isn't accepted in either the Collection ID
or the Field path
, and using .
, while not clearly forbidden, results in a generic error when trying to save the exemption. I'm also not sure if *
is allowed.
Index exemptions are based on collection ID and not collection path. In this case, you can enter bar
as the collection ID. This also means the exemption applies to all collections with ID bar
, regardless of hierarchy.
As for the fields, you can specify only a single field path per exemption. The "*" all-selector is not supported. There is a limit of 200 index exemptions so you wouldn't be able to exempt all 34571 fields. If possible, I suggest moving your fields into a map. Then you could disable indexing on the map field.
这篇关于如何在Firestore子文档上创建索引豁免?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!