diff --git a/server/src/infra/repositories/search.repository.ts b/server/src/infra/repositories/search.repository.ts index 0ff26a4f5f..8231931385 100644 --- a/server/src/infra/repositories/search.repository.ts +++ b/server/src/infra/repositories/search.repository.ts @@ -188,6 +188,7 @@ export class SearchRepository implements ISearchRepository { .addCommonTableExpression(cte, 'cte') .from('cte', 'res') .where('res.distance <= :maxDistance', { maxDistance }) + .orderBy('res.distance') .getRawMany(); }); return results.map((row) => ({ diff --git a/server/src/infra/sql/search.repository.sql b/server/src/infra/sql/search.repository.sql index 48a7fc8e5b..a11f8805a0 100644 --- a/server/src/infra/sql/search.repository.sql +++ b/server/src/infra/sql/search.repository.sql @@ -229,6 +229,8 @@ FROM "cte" "res" WHERE res.distance <= $3 +ORDER BY + res.distance ASC COMMIT -- SearchRepository.searchPlaces