Skip to content

Commit

Permalink
Merge pull request #29 from designmynight/fix-scroll-limit
Browse files Browse the repository at this point in the history
fix: overall scroll size and limit
  • Loading branch information
Will Taylor-Jackson authored Feb 1, 2018
2 parents 7ecc22b + e7e0806 commit 5a1f588
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/DesignMyNight/Elasticsearch/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ public function select($params, $bindings = [])
public function scrollSelect($params, $bindings = [])
{
$scrollTimeout = '30s';
$limit = min($params['body']['size'] ?? 100000, 100000);

$scrollParams = array(
'scroll' => $scrollTimeout,
'size' => min($params['body']['size'], 5000),
'size' => 500,
'index' => $params['index'],
'body' => $params['body']
);
Expand All @@ -187,8 +188,8 @@ public function scrollSelect($params, $bindings = [])

$numResults = count($results['hits']['hits']);

if ( $params['body']['size'] > $numResults ){
$results['scrollCursor'] = $this->scroll($scrollId, $scrollTimeout, $params['body']['size'] - $numResults);
if ( $limit >= $numResults ){
$results['scrollCursor'] = $this->scroll($scrollId, $scrollTimeout, $limit - $numResults);
}

return $results;
Expand Down

0 comments on commit 5a1f588

Please sign in to comment.