Currently
Currently, we allow something like this:
$builder->add('@field', OrderType::class, ['default' => 'ASC']);
This means if you specify
| User input |
Final query |
name: foo |
name:foo; @field: ASC |
name: foo; @field: desc |
name:foo; @field: DESC |
Would like
$builder
->add('@id', OrderType::class, ['default' => 'ASC', 'always' => 'append'])
->add('@field', OrderType::class, ['default' => 'ASC']);
This means if you specify
| User input |
Final query |
name: foo |
name:foo; @field: ASC; @id: ASC |
name: foo; @id: desc |
name:foo; @id: DESC |
name: foo; @field: desc |
name:foo; @field: DESC; @id: ASC |
So
- the fields marked
default would get appended if no user sort is given
- the fields marked both
default and always would get appended regarless of user input
This allows to stabilize order if you're sorting on a user-controllable property and all the values are the same, Elasticsearch will not keep the same order with each query.
Currently
Currently, we allow something like this:
This means if you specify
name: fooname:foo; @field: ASCname: foo; @field: descname:foo; @field: DESCWould like
This means if you specify
name: fooname:foo; @field: ASC; @id: ASCname: foo; @id: descname:foo; @id: DESCname: foo; @field: descname:foo; @field: DESC; @id: ASCSo
defaultwould get appended if no user sort is givendefaultandalwayswould get appended regarless of user inputThis allows to stabilize order if you're sorting on a user-controllable property and all the values are the same, Elasticsearch will not keep the same order with each query.