Skip to content

Commit

Permalink
fix: 검색 결과 대소문자 무시하도록 수정 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
gahyuun committed Jan 24, 2025
1 parent 1ffc20a commit 119832e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,9 @@ public SearchSpotListResponse searchSpot(final String keyword) {
if (keyword == null || keyword.trim().isEmpty()) {
return new SearchSpotListResponse(Collections.emptyList());
}
List<SpotEntity> spotEntityList = spotRepository.findTop10ByNameStartingWith(keyword);

List<SpotEntity> spotEntityList = spotRepository.findTop10ByNameStartingWithIgnoreCase(keyword);
if (spotEntityList.size() < SEARCH_LIMIT) {
List<SpotEntity> additionalSpots = spotRepository.findByNameContainingWithLimit(keyword,
List<SpotEntity> additionalSpots = spotRepository.findByNameContainingWithLimitIgnoreCase(keyword,
SEARCH_LIMIT - spotEntityList.size());
Set<Long> existingSpotIds = spotEntityList.stream()
.map(SpotEntity::getId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@
@Repository
public interface SpotRepository extends JpaRepository<SpotEntity, Long> {

List<SpotEntity> findTop10ByNameStartingWith(String prefix);
List<SpotEntity> findTop10ByNameStartingWithIgnoreCase(String keyword);

@Query(value = "SELECT * FROM spot WHERE name LIKE %:keyword% LIMIT :limit", nativeQuery = true)
List<SpotEntity> findByNameContainingWithLimit(@Param("keyword") String keyword, @Param("limit") int limit);
// TODO: 앱잼 이후 검색 결과 거리 순 정렬
@Query(value = "SELECT *" +
"FROM spot " +
"WHERE name ILIKE %:keyword% " +
"LIMIT :limit", nativeQuery = true)
List<SpotEntity> findByNameContainingWithLimitIgnoreCase(@Param("keyword") String keyword,
@Param("limit") int limit);

List<SpotEntity> findAllByLatitudeIsNullOrLongitudeIsNullOrGeomIsNullOrLegalDongIsNull();

Expand Down

0 comments on commit 119832e

Please sign in to comment.