Google云数据存储中的追溯索引 [英] Retroactive indexing in Google Cloud Datastore

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

问题描述

我的模型中有很多属性,我目前不需要编制索引,但可以想象,我可能需要在未来的某个未知点编制索引。如果我现在明确地为一个属性设置了 indexed = False ,但是改变了我的想法,那么Datastore会在那一刻自动重建整个索引,包括以前写入的数据吗?是否有任何其他影响采取这种方法?

解决方案

不,更改索引= True索引= False(反之亦然)只会影响在该点之后写入数据存储的实体。 下面是关于它和相关段落的文档
$ b


同样,将属性从索引更改为未索引仅影响随后写入数据存储的实体。任何具有该属性的现有实体的索引条目将一直存在,直到实体被更新或删除。为了避免不必要的结果,您必须清除所有查询的代码,这些查询通过(现在未指定索引的)属性进行过滤或排序。

如果您稍后决定要开始索引属性,则必须通过实体并重新放入数据存储区。


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

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



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



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?

解决方案

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云数据存储中的追溯索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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