From e7e0806819abdefe6f365294f42b7d84bcf23def Mon Sep 17 00:00:00 2001 From: Will Taylor-Jackson Date: Thu, 1 Feb 2018 18:27:19 +0000 Subject: [PATCH] fix: overall scroll size and limit --- src/DesignMyNight/Elasticsearch/Connection.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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;