Skip to content

Potentially broken sorting in unbounded queries built with NativeQueryBuilder #2745

Closed
@jorge-marques

Description

@jorge-marques

My team is using the withSort(Function<SortOptions.Builder, ObjectBuilder<SortOptions>> fn) method in NativeQueryBuilder to include sort criteria for an unbounded query. This sets the sortOptions field when the query is built.

When the query is executed, the current implementation of doFindUnbounded in ReactiveElasticsearchTemplate calls addSort on the built query with Sort.by("_shard_doc") as the argument. This results in both sort and sortOptions being set, with sort having precedence when the query object is converted to JSON, breaking the expected result order.

We're on 5.1.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions