Skip to content
Snippets Groups Projects
Commit ddacb5db authored by Mantas Varatiejus's avatar Mantas Varatiejus
Browse files

Revert old sort format

parent 1f9caebf
No related branches found
No related tags found
No related merge requests found
......@@ -125,15 +125,12 @@ class TopHitsAggregation extends AbstractAggregation
*/
public function getArray()
{
$output = $this->getSort() ? $this->getSort()->toArray() : [];
$output = array_filter(
array_merge(
$output,
[
'size' => $this->getSize(),
'from' => $this->getFrom(),
]
),
[
'sort' => $this->getSort() ? $this->getSort()->toArray() : null,
'size' => $this->getSize(),
'from' => $this->getFrom(),
],
function ($val) {
return (($val || is_array($val) || ($val || is_numeric($val))));
}
......
......@@ -103,6 +103,6 @@ class FieldSort implements BuilderInterface
$this->field => empty($fieldValues) ? new \stdClass() : $fieldValues,
];
return [$this->getType() => $output];
return $output;
}
}
......@@ -14,6 +14,7 @@ namespace ONGR\ElasticsearchDSL\Tests\Unit\DSL;
use ONGR\ElasticsearchDSL\Query\MissingQuery;
use ONGR\ElasticsearchDSL\Query\TermQuery;
use ONGR\ElasticsearchDSL\Search;
use ONGR\ElasticsearchDSL\Sort\FieldSort;
/**
* Test for Search.
......@@ -242,6 +243,19 @@ class SearchTest extends \PHPUnit_Framework_TestCase
(new Search())->addQuery(new TermQuery('foo', 'bar'))->addFilter(new MissingQuery('baz')),
];
$cases['sort_by_price'] = [
[
'sort' => [
[
'price' => [
'order' => 'asc',
],
],
],
],
(new Search())->addSort(new FieldSort('price', 'asc')),
];
return $cases;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment