index.yaml reference

App Engine predefines a simple index on each property of an entity. An App Engine application can define further custom indexes in an index configuration file named index.yaml. You can tune indexes manually by editing the index.yaml file before uploading the application.

Example

The following is an example of an index.yaml file:

indexes:

- kind: Cat
  ancestor: no
  properties:
  - name: name
  - name: age
    direction: desc

- kind: Cat
  properties:
  - name: name
    direction: asc
  - name: whiskers
    direction: desc

# This pound sign is the syntax for a comment.

- kind: Store
  ancestor: yes
  properties:
  - name: business
    direction: asc
  - name: owner
    direction: asc

Syntax

The syntax of index.yaml is the YAML format. The index.yaml file has a single list element called indexes. Each element in the list represents an index for the application.

The index items can have the following elements:

Element Description
kind Required. The kind of the entity for the query.
properties

A list of properties to include as columns of the index, in the order to be sorted: properties used in equality filters first, followed by the property used in inequality filters, then the sort orders and their directions.

Each element in this list has the following elements:

name
The datastore name of the property.
direction
The direction to sort, either asc for ascending or desc for descending. This is only required for properties used in sort orders of the query, and must match the direction used by the query. The default is asc.
ancestor yes if the query has an ancestor clause (). The default is no.

Deploying the index configuration file

The index.yaml file can reside anywhere in your source code directory.

To deploy the dispatch configuration file without otherwise altering the currently serving version, use one of the following commands in the directory containing your dispatch file, depending on your environment:

gcloud

gcloud app deploy index.yaml

Maven

mvn appengine:deployIndex index.yaml

Gradle

gradle appengineDeployIndex index.yaml

IDE

If you use IntelliJ or Eclipse, you select the individual configuration files to be deployed using the deployment form.

Deleting unused indexes

When you change or remove an index from the index configuration, the original index is not deleted from App Engine automatically. This gives you the opportunity to leave an older version of the app running while new indexes are being built, or to revert to the older version immediately if a problem is discovered with a newer version.

When you are sure that old indexes are no longer needed, you can delete them from App Engine as follows:

gcloud datastore cleanup-indexes index.yaml
Was this page helpful? Let us know how we did:

Send feedback about...

App Engine standard environment for Java