0

在我的业务逻辑中,我首先需要检查 Appengine Search API 索引是否存在。如果存在,然后我确定长度。

for index in search.list_indexes(fetch_schema=False):
   if name == index.name:
        indexed = True

问题是没有返回整个列表。所以我尝试了以下方法:

for index in search.list_indexes(fetch_schema=False, limit=500):
    logging.info("sent name: " + name + " : official index name: " + index.name)

结果是将其限制为 100 个索引。我肯定错过了什么。

我的问题有两个:

  1. 有没有更好的方法来检查索引是否存在?(我的方式感觉不对)

  2. 当我们显然有更多时,为什么 list_indexes 只返回 100?

编辑: - - - - - - - - - - - - - - - - - - - - -

根据@skreft 的建议,我更新了我的代码:

    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`

但问题是我收到了一条非常神秘的错误消息,并且我非常明确地遵循了文档。其他人有这种情况吗?(以下错误):

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
4

1 回答 1

0

尝试使用参数 start_index_name 和 include_start_index。

有关更多信息,请参阅文档

于 2012-06-21T17:54:38.783 回答