Skip to content

Commit ae2f89c

Browse files
committed
Fix a bug of sample code: may use invalid token if index is empty.
1 parent 42423fc commit ae2f89c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

examples/search_index.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ def match_all_query(table_name, index_name):
1616
all_rows = []
1717
next_token = None
1818

19-
while not all_rows or next_token:
19+
while True:
2020
rows, next_token, total_count, is_all_succeed = client.search(table_name, index_name,
2121
SearchQuery(query, next_token=next_token, limit=100, get_total_count=True),
2222
columns_to_get=ColumnsToGet(['k', 't', 'g', 'ka', 'la'], ColumnReturnType.SPECIFIED))
2323
all_rows.extend(rows)
2424

25+
if not next_token: # data all returned
26+
break
27+
2528
for row in all_rows:
2629
print(row)
2730

@@ -185,6 +188,8 @@ def prepare_data(rows_count):
185188
client.put_row(table_name, Row(pk, cols))
186189

187190
print ('End prepare data.')
191+
print ('Wait for data sync to search index.')
192+
time.sleep(10)
188193

189194
def prepare_table():
190195
table_meta = TableMeta(table_name, [('PK1', 'INTEGER'), ('PK2', 'STRING')])

0 commit comments

Comments
 (0)