Fix scan queries with multiple shards

As it turns out, elasticsearch is weird in two ways:

* The `size` parameter on scan queries refers to the number of hits to
  return *per shard*, not in total.
* If any of the shards have run out of results, the entire response
  has a 500 status code but can still contain results.