diff --git a/src/DesignMyNight/Elasticsearch/Connection.php b/src/DesignMyNight/Elasticsearch/Connection.php index 2140017..da1d9c5 100644 --- a/src/DesignMyNight/Elasticsearch/Connection.php +++ b/src/DesignMyNight/Elasticsearch/Connection.php @@ -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'] ); @@ -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;