Skip to content

Fix sort direction ignored in GeoSearchStoreCommandArgs.sort().#3345

Open
yeonsu00 wants to merge 1 commit intospring-projects:mainfrom
yeonsu00:fix/geosearchstore-sort-direction
Open

Fix sort direction ignored in GeoSearchStoreCommandArgs.sort().#3345
yeonsu00 wants to merge 1 commit intospring-projects:mainfrom
yeonsu00:fix/geosearchstore-sort-direction

Conversation

@yeonsu00
Copy link
Copy Markdown

Problem

GeoSearchStoreCommandArgs.sort(Direction) always assigned Direction.ASC
regardless of the provided argument:

public GeoSearchStoreCommandArgs sort(Direction direction) {
    Assert.notNull(direction, "Sort direction must not be null");
    sortDirection = Direction.ASC; // direction parameter ignored
    return this;
}

This caused sortDescending() to have no effect, and the SORT DESC flag
was never passed to the underlying Redis GEOSEARCHSTORE command in either
Lettuce or Jedis drivers.

The equivalent method in GeoSearchCommandArgs is implemented correctly and
served as a reference.

Fix

Assign the provided direction argument directly:

sortDirection = direction;

Testing

Added integration test geoSearchAndStoreShouldRespectSortDirection that:

  • Adds three members at different distances from a reference point (Palermo, Agrigento, Catania)
  • Calls searchAndStore with sortDescending().limit(1)
  • Verifies that only the farthest member (Catania) is stored in the destination key

Closes #3342

  • You have read the Spring Data contribution guidelines.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.
  • You added yourself as author in the headers of the classes you touched. Amend the date range in the Apache license header if needed. For new types, add the license header (copy from another file and set the current year only).

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 10, 2026
The sort(Direction) method always assigned Direction.ASC regardless of the provided argument, causing sortDescending() to have no effect.

Add test to verify that sortDescending() stores only the farthest member when combined with limit(1).

Closes spring-projects#3342

Signed-off-by: yeonsu00 <yeonsu00@gmail.com>
Signed-off-by: Kim yeonsu <yeonsu00@gmail.com>
@yeonsu00 yeonsu00 force-pushed the fix/geosearchstore-sort-direction branch from a588cdc to 07bc1db Compare April 10, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix sort direction ignored in GeoSearchStoreCommandArgs.sort()

2 participants