pdphilip / laravel-elasticsearch

Laravel Elasticsearch: An Elasticsearch implementation of Laravel's Eloquent ORM
MIT License
86 stars 16 forks source link

[Fixed] Sorting on Multiple Fields orderBy set only one field #18

Closed SergejGuruliov closed 5 months ago

SergejGuruliov commented 6 months ago

Sorting on Multiple Fields orderBy set only one field

pdphilip/elasticsearch/src/DSL/QueryBuilder.php:380 $field = array_shift($value);

pdphilip commented 6 months ago

Hey @SergejGuruliov , this is actually a bug.

You should be able to sort on multiple fields as per standard eloquent, ex:

Product::orderBy('status')->orderByDesc('price')->get();

However, only the first order clause is being processed.

This will be fixed in the new 3.x major release - ca. 1 week from now. Will close this issue to notify you then.

Thanks for flagging this.

pdphilip commented 5 months ago

@SergejGuruliov - this bug has been fixed in the new 3.x version