Google Cloud Datastore 中的追溯索引 [英] Retroactive indexing in Google Cloud Datastore

查看:23
本文介绍了Google Cloud Datastore 中的追溯索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的模型中有许多属性目前不需要编入索引,但可以想象我可能希望在未来某个未知点编入索引.如果我现在为一个属性显式设置 indexed=False 但以后改变主意,Datastore 会在那时自动重建整个索引,包括以前写入的数据吗?采取这种方法还有其他影响吗?

There are many properties in my model that I currently don't need indexed but can imagine I might want indexed at some unknown point in the future. If I explicitly set indexed=False for a property now but change my mind down the road, will Datastore rebuild the entire indices automatically at that point, including for previously written data? Are there any other repercussions for taking this approach?

推荐答案

否,将 indexed=True 更改为 indexed=False(反之亦然)只会影响在该点之后写入数据存储区的实体.这里是讨论它的文档和相关段落:

No, changing indexed=True to indexed=False (and vice-versa) will only affect entities written after that point to the datastore. Here is the documentation that talks about it and the relevant paragraph:

同样,将属性从已编制索引更改为未编制索引只会影响随后写入数据存储区的实体.具有该属性的任何现有实体的索引条目将继续存在,直到实体被更新或删除.为避免出现不需要的结果,您必须清除所有按(现已未编入索引的)属性过滤或排序的查询的代码.

Similarly, changing a property from indexed to unindexed only affects entities subsequently written to the Datastore. The index entries for any existing entities with that property will continue to exist until the entities are updated or deleted. To avoid unwanted results, you must purge your code of all queries that filter or sort by the (now unindexed) property.

如果您稍后决定要开始索引属性,则必须检查实体并将它们重新放入数据存储区.

If you decide later that you want to starting indexing properties, you'll have to go through your entities and re-put them into the datastore.

但是请注意,将属性从未编入索引更改为编入索引不会影响更改之前可能已创建的任何现有实体.对该属性进行过滤的查询不会返回此类现有实体,因为这些实体在创建时并未写入查询的索引.为了使以后的查询可以访问实体,您必须将它们重写到数据存储区,以便将它们输入到适当的索引中.也就是说,您必须为每个这样的现有实体执行以下操作:

Note, however, that changing a property from unindexed to indexed does not affect any existing entities that may have been created before the change. Queries filtering on the property will not return such existing entities, because the entities weren't written to the query's index when they were created. To make the entities accessible by future queries, you must rewrite them to the Datastore so that they will be entered in the appropriate indexes. That is, you must do the following for each such existing entity:

从数据存储中检索(获取)实体.

Retrieve (get) the entity from the Datastore.

将实体写(放)回数据存储区.

Write (put) the entity back to the Datastore.

这篇关于Google Cloud Datastore 中的追溯索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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