5
result = search.get_indexes(namespace='', offset=0, limit=999, start_index_name='f35cef2dfb9a8f34e381386ec5a1f7ee', include_start_index=True, fetch_schema=False)

但是,这里没有 id/index

如何在搜索 API 中仅获取记录的 ID/索引?帮助 !!

4

2 回答 2

1

您可以使用 get_range 函数作为

响应 = index.get_range(start_id="0", ids_only=True)

https://developers.google.com/appengine/docs/python/search/indexclass#Index_get_range

于 2013-12-14T08:49:02.370 回答
1

上面的代码只会为您提供第一批 doc_ids,我必须花费数小时才能找到它。使用以下代码获取所有 doc_ids...

from google.appengine.api import search

index = search.Index('YOUR_INDEX_NAME')
document_ids = [document.doc_id for document in index.get_range(start_id="0", ids_only=True)]
    while len(document_ids)>1:
      for doc_id in document_ids:
        print doc_id# Do whatever you want with these ID's
      document_ids = [document.doc_id for document in index.get_range(start_id=doc_id, ids_only=True)]
于 2017-08-14T15:21:11.537 回答