GetResponse 类

GetResponse 类表示为返回有关文档和索引的信息而调用的方法的结果。

注意:**我们不再建议采用这种解决方案。**使用此 API 的应用只能在 Python 2 运行时环境中运行,并且必须先升级到[建议的解决方案] (/appengine/docs/standard/python/migrate-to-python3/migrating-services#migration_paths_for_bundled_services),然后才能迁移到 Python 3 运行时。

GetResponse 在模块 google.appengine.api.search 中定义。

简介

如果调用 index.get_range()search.get_indexes(),则系统将返回 GetResponse 对象。您可以迭代 GetResponse 的实例,这可返回实例中拥有 results 属性的成员。该属性的内容取决于创建 GetResponse 实例的调用类型。

例如,以下代码展示了如何使用 GetResponse 来确定哪些文档已成功删除。在本例中,迭代返回文档

response = index.get_range()
for document in response:
    print "document ", document

构造函数

GetResponse 类的构造函数定义如下:

class GetResponse(results=None)

构造类 GetResponse 的实例。

参数

results

results 属性的初始值。

结果值

GetResponse 类的新实例。

异常

TypeError

参数类型无效或者传递了未知特性。

ValueError

参数赋值无效。

属性

GetResponse 类的实例具有以下属性:

results

结果列表,其类型取决于返回对象的调用。如果调用 get_range(),则 results 的返回值为文档列表,根据文档标识符按降序排列。如果调用 search.get_indexes(),则 results 的返回值为索引列表。