Trying to delete the (defaut) Datastore database I get this message:
400: Database contains Google App Engine search data.
To delete this database you must first remove the search data.
This data is there, unused, from years and years ago when this project used the Python 2.7 appengine just for while. It's a risible weight so never bothered deleting.
Going to https://console.cloud.google.com/appengine/search?project=<PROJECT_ID> I see there's no option to remove the search data.
In App Engine Search API docs there is some python code to delete an index where I probably need Python 2.7 which I don't even have installed anymore. Everywhere deprecation warnings.
Using a new project is NOT an option as this is a production environment which is tied to so many other systems and it would be a pain in the heck to change all the references to a new project — or at least it's not an option for such a meaningless constraint.
And also I exclude using another database than (default), I would lose the free tier quota and also the application code should be adapted to use another db.
This also prevents me being able to do a disaster recovery using backups created with the recently added gcloud alpha firestore backups feature.
Edit:
Trying to follow the documentation I've been pointed to and also this Installing the App Engine services SDK I tried to modify my existing Flask app so I could access search from a flask shell prompt.
I added this to my requirements.txt
appengine-python-standard>=1.0.0
Then, after creating a fresh new virtualenv including the above, I added the wsgi_app lines to my flask app:
from flask import Flask
from google.appengine.api import wrap_wsgi_app
app = Flask(__name__)
app.wsgi_app = wrap_wsgi_app(app.wsgi_app)
And in flask shell I tried:
In [1]: from google.appengine.api import search
In [2]: index = search.Index('general-index')
In [3]: index.get_range(ids_only=True)
---------------------------------------------------------------------------
RPCFailedError Traceback (most recent call last)
Cell In[3], line 1
----> 1 index.get_range(ids_only=True)
[...]
RPCFailedError: Attempted RPC call without active security ticket
It seems I have to bring in also the local development server
gcloud components install app-engine-python
which on my linux box can be done with:
You cannot perform this action because the Google Cloud CLI component manager
is disabled for this installation. You can run the following command
to achieve the same result for this installation:
sudo apt-get install google-cloud-sdk-app-engine-python
which is bringing in Python2.7 as well
$ sudo apt-get install google-cloud-sdk-app-engine-python
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
google-cloud-sdk libpython2.7-minimal libpython2.7-stdlib python2.7 python2.7-minimal
Suggested packages:
google-cloud-sdk-app-engine-java google-cloud-sdk-pubsub-emulator google-cloud-sdk-bigtable-emulator google-cloud-sdk-datastore-emulator kubectl python2.7-doc binfmt-support
The following packages will be REMOVED:
google-cloud-cli
The following NEW packages will be installed:
google-cloud-sdk google-cloud-sdk-app-engine-python libpython2.7-minimal libpython2.7-stdlib python2.7 python2.7-minimal
0 upgraded, 6 newly installed, 1 to remove and 30 not upgraded.
Need to get 117 MB of archives.
After this operation, 60,7 MB of additional disk space will be used.
All this to delete 13,4kb worth of search index...
Also I suspect that running the delete_index routine in dev_appserver.py would eventually delete only local (inexisting) search indexes leaving the one in cloud I want to remove untouched.
Can someone from Google shed a light on this please???
Search API is available for Python 3 via the bundled API/Services.
See documentation on how to enable bundled API for Python 3 in an App.
After enabling it, you can then use the python code snippet you referenced (update any Python 3 incompatible bits) to delete your index