Google App Engine搜索API

时间:2017-01-04 04:52:32

标签: google-app-engine google-app-engine-python

我想从doc_ids列表中检索文档列表。类似于在SQL中执行以下操作:

SELECT * FROM Documents WHERE id IN (1,2,3,167,91)

我在documentation中看到了这个方法,但只检索了一个文档。为了提高效率,我想进行批量检索。这可能吗?

1 个答案:

答案 0 :(得分:0)

我认为没有批量get功能,但有一个异步版本(get_async搜索https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.api.search.search),所以你可以做类似的事情(未经测试的伪代码):

# query for docs ids in advance
futures = []
for id_ in doc_ids:
    futures.append(index.get_async(id_))

# dereference the futures when you need them
ids = [x.get_result() for x in futures]