Skip to content

Commit

Permalink
Merge pull request #141 from bakaphp/feature-elastic-sort
Browse files Browse the repository at this point in the history
[0.7] feature:  allow to limit elastic search queries manually
  • Loading branch information
kaioken authored Aug 16, 2021
2 parents 5a021de + 2250e01 commit d9a11fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Contracts/Http/Api/CrudElasticBehaviorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ protected function processRequest(RequestInterface $request) : array
//parse the request
$parse = new QueryParser($this->model, $request->getQuery());
$parse->setAdditionalQueryFields($this->additionalSearchFields);
if ($this->customSort) {
$parse->setSort($this->customSort);
}

if ($this->customLimit) {
$parse->setLimit($this->customLimit);
}

if ($this->customColumns) {
$parse->setFields($this->customColumns);
}
//convert to SQL
return [
'sql' => $parse
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/Contracts/Http/CrudElasticBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class CrudElasticBehaviorTest extends PhalconUnitTestCase

protected ?RequestInterface $request = null;
public $model;
protected $customSort = null;
protected $customLimit = null;
protected $customColumns = null;

public function testIndex()
{
Expand Down

0 comments on commit d9a11fd

Please sign in to comment.