Skip to content

[Core] apply to specify "always on" sort fields #263

@dkarlovi

Description

@dkarlovi

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions