In my business logic, I first need to check if an Appengine Search API Index exists. If it exists, I then determine length.
for index in search.list_indexes(fetch_schema=False):
if name == index.name:
indexed = True
The problem is that the entire list is not being returned. So I tried the following:
for index in search.list_indexes(fetch_schema=False, limit=500):
logging.info("sent name: " + name + " : official index name: " + index.name)
The results was that it limited it to 100 indexes. I must be missing something.
My question is two-fold:
-
Is there a better way to check if an index exists? (my way feels wrong)
-
Why might list_indexes only return 100 when we clearly have more?
Edit:—————————————–
Based on @skreft’s suggestion, I updated my code with this:
for index in search.list_indexes(fetch_schema=False, include_start_index=True, start_index_name="some_index", limit=1000):
logging.info("sent name: " + name + " : official index name: " + index.name)
if name == index.name:
indexed = True`enter code here`
But the problem is I’m getting a very cryptic error message, and I followed the docs pretty explicitly. Anybody else have this happen? (error below):
Traceback (most recent call last):
File "/base/data/home/apps/s~searchbertha-hrd/82.359784956262345840/models.py", line 1898, in build_searchable_index
for index in search.list_indexes(fetch_schema=False, include_start_index=True, start_index_name=name, limit=1000):
File "/base/python_runtime/python_lib/versions/1/google/appengine/api/search/search.py", line 675, in list_indexes
raise _ToSearchError(e)
InvalidRequest
Try using the parameters start_index_name and include_start_index.
See the docs for further information.