Search Results

Search results include Enumerable so you can iterate over them using each or any method defined in Enumerable.

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 do |search|
  search.amount <= "20.00"
end
search_results.maximum_size
#=> 33

Search Limit

We currently cap searches to 10,000 maximum results.