Last active
December 7, 2015 20:38
-
-
Save shentonfreude/747300dbd0438a628264 to your computer and use it in GitHub Desktop.
AWS CloudSearch with pages: limit of 10,000 results but can go backward and forward
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
# found is always the same | |
# start is the index into the total results, not a page of size results | |
cs = boto3.client('cloudsearchdomain', | |
endpoint_url='https://search-name-xxx.us-east-1.cloudsearch.amazonaws.com', | |
region_name='us-east-1') | |
size = 4 | |
start = 0 | |
while True: | |
ret = cs.search(query='nasa', start=start, size=4) | |
found = ret['hits']['found'] | |
hit = ret['hits']['hit'] | |
if not hit: | |
break | |
print('f={} p={} {}'.format(found, start, ' | '.join([h['id'] for h in hit]))) | |
start += size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment