2

We are hosting a NodeJS application on compute engine, which connect to google DataStore using gcloud-node. Simple queries are running fine, but complex queries with multipple selects are giving "412: precondition failed" error. More details at": Multiple select in google datastore query throwing ApiError: Precondition Failed error in node

I understand this error is due to the fact I have not configured datastore-indexes.xml. Being a newbie in GCP world. Could you please help me where can I define my datastore-indexes.xml file inside my project.

Community
  • 1
  • 1
  • this question is answered here http://stackoverflow.com/questions/34928582/multiple-select-in-google-datastore-query-throwing-apierror-precondition-failed – Ashish Anand Jan 23 '16 at 22:09

1 Answers1

2

You can also use the gcloud preview app tool with an index.yaml file to specify an indexing policy.

For example, if you need an index on user and timestamp on LoginTimes:

indexes:
 - kind: LoginTimes
   properties:
   - name: user
   - name: timestamp
     direction: desc
E. Anderson
  • 3,405
  • 1
  • 16
  • 19
  • 1
    Note that for production use, you probably want to manually update your datastore indexes rather than automatically uploading `index.yaml` each time. In particular: 1) It can take some time to update your indexes, so you probably want to upload new indexes *before* your app. 2) If you are using multiple modules, they all share the same datastore and indexes, so you probably want to keep the datastore configuration in e.g. a separate directory. – E. Anderson Jan 24 '16 at 17:09