MatchAllQuery可以匹配所有行,常用于查询表中数据总行数,或者随机返回几条数据。
前提条件
参数
参数 | 描述 |
---|---|
query | 设置查询类型为MatchAllQuery。 |
table_name | 数据表名称。 |
index_name | 多元索引名称。 |
limit | 本次查询需要返回的最大数量。
如果只为了获取行数,无需获取具体数据,可以设置limit=0,即不返回任意一行数据。 |
get_total_count | 是否返回匹配的总行数,默认为false,表示不返回。
返回匹配的总行数会影响查询性能。 |
columns_to_get | 是否返回所有列。
|
示例
query = MatchAllQuery()
all_rows = []
next_token = None
while not all_rows or next_token:
rows, next_token, total_count, is_all_succeed = client.search(table_name, index_name,
SearchQuery(query, next_token=next_token, limit=100, get_total_count=True),
columns_to_get=ColumnsToGet(['k', 't', 'g', 'ka', 'la'], ColumnReturnType.SPECIFIED))
all_rows.extend(rows)
for row in all_rows:
print row
print 'Total rows:', len(all_rows)
在文档使用中是否遇到以下问题
更多建议
匿名提交