So I'm using Datastore as my DB with the NodeJS client and I'm making an aggregate query. I have an index.yaml setup to support getting counts, sums and such that has worked up until now.
I tried creating a composite index for one of my Kinds and accidentally misspelled the Kind in my index.yaml, but I reversed this, ran gcloud datastore indexes cleanup and then gcloud datastore indexes create.
The new composite index shows up in my Datastore Indexes tab in GCP but when I try to make the request to my Node service that makes this aggregate query, an error is raised, and I'm still prompted to create the composite index by adding it to index.yaml. (error: Error: 9 FAILED_PRECONDITION: no matching index found. recommended index is: ) To clarify, this is different than the error that tells me that the index is in the process of being created and this error still appears no matter how much time passes.
Has anyone ran into this before? I'm at my wits end.
It's possible that the Datastore has not yet fully processed your gcloud datastore indexes cleanup
and create
commands. Although the new index appears in the UI, it might not be fully operational for queries.
Here are some troubleshooting tips:
Patience with Index Processing:
Accuracy in Index Definition:
index.yaml
file for any typos or errors. Ensure that the Kind name and property names in the index definition exactly match those in your application.Confirm Index Creation:
gcloud datastore indexes list
command to check the status of your new index. This will confirm whether the index has been created and is ready for use.Client-Side Data Handling:
Inspect Error Messages:
Manage Stale Indexes:
gcloud datastore indexes cleanup
to remove unused indexes. However, proceed with caution, as this might inadvertently affect other parts of your application.It turns out that I had my service env pointing to the wrong GCP project. Thank you for your help, though!