Retroactive indexing in Google Cloud Datastore

前端 未结 2 2048
借酒劲吻你
借酒劲吻你 2020-12-06 12:20

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

2条回答
  •  -上瘾入骨i
    2020-12-06 12:32

    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.

提交回复
热议问题