Search Results
Searches return a ResourceCollection which can be itereated over like a list.
search_results = braintree.Transaction.search([
braintree.TransactionSearch.amount <= "20.00"
])
for transaction in search_results.items:
print transaction.id
Race Conditions
To optimize the processing of large searches, data is retrieved from the server in chunks. Initially the server returns a list of ids that matched the search criteria, and then the clients request the full records in chunks. While you’re iterating over search results, two race conditions exist.
Records are Deleted
It’s possible for a record to be deleted between the time that the server returned the list of ids that matched the search criteria and when the client requested full details for that id. In this case, that record is skipped.
Records are Updated
It’s possible for a record to be updated between the time that the server returned the list of ids that matched the search criteria and when the client requested full details. In this case, if the record still matches the search criteria, it will be returned. If it no longer matches the search criteria, it will not be returned.
Maximum Size
Because of the race conditions described above, you cannot know specifically how many search results you will get when you’re iterating over them. However, you do know the maximum number of results that will be given.
search_results = braintree.Transaction.search([
braintree.TransactionSearch.amount <= "20.00"
])
search_results.maximum_size
# e.g. 33
Search Limit
We currently cap searches to 10,000 maximum results.