Skip to main content

indexes

Creates, updates, deletes, gets or lists a indexes resource.

Overview

Nameindexes
TypeResource
Idgoogle.datastore.indexes

Fields

NameDatatypeDescription
ancestorstringRequired. The index's ancestor mode. Must not be ANCESTOR_MODE_UNSPECIFIED.
indexIdstringOutput only. The resource ID of the index.
kindstringRequired. The entity kind to which this index applies.
projectIdstringOutput only. Project ID.
propertiesarrayRequired. An ordered sequence of property names and their index attributes. Requires: * A maximum of 100 properties.
statestringOutput only. The state of the index.

Methods

NameAccessible byRequired ParamsDescription
getSELECTindexId, projectIdGets an index.
listSELECTprojectIdLists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.
createINSERTprojectIdCreates the specified index. A newly created index's initial state is CREATING. On completion of the returned google.longrunning.Operation, the state will be READY. If the index already exists, the call will return an ALREADY_EXISTS status. During index creation, the process could result in an error, in which case the index will move to the ERROR state. The process can be recovered by fixing the data that caused the error, removing the index with delete, then re-creating the index with create. Indexes with a single property cannot be created.
deleteDELETEindexId, projectIdDeletes an existing index. An index can only be deleted if it is in a READY or ERROR state. On successful execution of the request, the index will be in a DELETING state. And on completion of the returned google.longrunning.Operation, the index will be removed. During index deletion, the process could result in an error, in which case the index will move to the ERROR state. The process can be recovered by fixing the data that caused the error, followed by calling delete again.

SELECT examples

Lists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.

SELECT
ancestor,
indexId,
kind,
projectId,
properties,
state
FROM google.datastore.indexes
WHERE projectId = '{{ projectId }}';

INSERT example

Use the following StackQL query and manifest file to create a new indexes resource.

/*+ create */
INSERT INTO google.datastore.indexes (
projectId,
ancestor,
properties
)
SELECT
'{{ projectId }}',
'{{ ancestor }}',
'{{ properties }}'
;

DELETE example

Deletes the specified indexes resource.

/*+ delete */
DELETE FROM google.datastore.indexes
WHERE indexId = '{{ indexId }}'
AND projectId = '{{ projectId }}';