spring-projects / spring-data-elasticsearch

Provide support to increase developer productivity in Java when using Elasticsearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-elasticsearch/
Apache License 2.0
2.92k stars 1.33k forks source link

Order Mode not set correctly through constructor #2897

Closed oraum closed 6 months ago

oraum commented 6 months ago

Hi,

I recently stumbled upon an unexpected behavior when trying to sort a query response using org.springframework.data.elasticsearch.core.query.Order.

Creating a new order like new Order(Sort.Direction.DESC, "somefield", Mode.min); results in mode being null instead of Min.min.

When looking at the other constructors I could trace the error down to line 72 where null is passed instead of mode:

public Order(Sort.Direction direction, String property, Sort.NullHandling nullHandlingHint, @Nullable Mode mode,
    @Nullable String unmappedType) {
this(direction, property, nullHandlingHint, null, unmappedType, null); // <-- instead of this(direction, property, nullHandlingHint, mode, unmappedType, null);
}

This should be trivial to fix - I could provide a pull request if you're interested. Otherwise if this behavior is intended, a little note would be helpful :)

thanks and best regards

sothawo commented 6 months ago

Thanks for finding and reporting. I just fixed it directly, a full PR seems like an overkill