diff --git a/Controllers/EntityController.php b/Controllers/EntityController.php index ca4bb4b..d8eef32 100644 --- a/Controllers/EntityController.php +++ b/Controllers/EntityController.php @@ -437,7 +437,6 @@ protected function convertQueryToElasticsearchRequest($query, $limit = null, $of { /* @var ElasticquentTrait $model */ $model = $this->getModel(); - // Complex query if (is_array($query)) { $params = [ @@ -446,6 +445,14 @@ protected function convertQueryToElasticsearchRequest($query, $limit = null, $of 'body' => $this->translateQuery($query), ]; + if (is_numeric($limit)) { + $params = array_merge($params, ['size' => $limit]); + } + + if (is_numeric($offset)) { + $params = array_merge($params, ['from' => $offset]); + } + // Simple query } else { $params = $model->getBasicEsParams(true, true, true, $limit, $offset); diff --git a/tests/integration/EntityTest.php b/tests/integration/EntityTest.php index 0daba61..6911b60 100644 --- a/tests/integration/EntityTest.php +++ b/tests/integration/EntityTest.php @@ -303,6 +303,8 @@ public function testGetAllPaginatedComplexSearch($path) 'index' => 'defaultIndex', 'type' => 'someTypeName', 'body' => ['query' => ['bool' => ['must' => [['match_phrase_prefix' => ['_all' => 'search term']], ['match_phrase_prefix' => ['author_id' => 'some UUID']], ['nested' => ['path' => '_tags', 'query' => ['bool' => ['must' => ['match_phrase_prefix' => ['_tags.tag_id' => 'tag ID 1']]]]]], ['nested' => ['path' => '_tags', 'query' => ['bool' => ['must' => ['match_phrase_prefix' => ['_tags.tag_id' => 'tag ID 2']]]]]]]]]], + 'size' => 10, + 'from' => 0, ]) ->andReturn($resultsMock); @@ -352,6 +354,8 @@ public function testGetAllPaginatedComplexSearchMatchAll($path) 'index' => 'defaultIndex', 'type' => 'someTypeName', 'body' => ['query' => ['match_all' => []]], + 'size' => 10, + 'from' => 0, ]) ->andReturn($resultsMock);