[英]Boto CloudSearch Searchable documents count
我想知道如何使用boto获取可搜索文档的数量? 当我尝试:
import boto.cloudsearch
from boto.cloudsearch.domain import Domain
conn = boto.cloudsearch.connect_to_region("us-east-1")
domain = Domain(conn, conn.describe_domains()[0])
print domain.num_searchable_docs
我懂了
boto.exception.BotoServerError: BotoServerError: 401 Unauthorized
<ErrorResponse xmlns="http://cloudsearch.amazonaws.com/doc/2011-02-01/">
<Error>
<Type>Sender</Type>
<Code>NotAuthorized</Code>
</Error>
<RequestId>3a8f8731-137a-11e4-9620-892c28eddd75</RequestId>
</ErrorResponse>
而且cloudsearch2.domain.Domain
没有num_searchable_docs
字段
从Amazon的CloudSearch 文档中 ,我发现必须以q=matchall&q.parser=structured&size=0
,因此对于boto来说,查询如下。
from boto.cloudsearch2.layer2 import Layer2
layer2 = Layer2()
domain = layer2.lookup('my-domain')
search = domain.get_search_service()
results = search.search(q='matchall', parser='structured', size=0)
return results.hits
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.