-
Notifications
You must be signed in to change notification settings - Fork 0
MongoDB Atlas search 사용하도록 변경 #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 가수 검색의 경우 nori가 아닌 edege n-gram을 사용해 자동완성 효과를 낼 수 있도록 작성했습니다. - mongodb에서는 id만 반환하기 떄문에, 해당 id 리스트를 가지고 페이지네이션을 구현할 수 있도록 IdsWithHasNext를 작성해주었습니다.
- idsWithHasNext을 가지고 가수 데이터로 변환할 때, id 리스트 순서대로 가져올 수 있도록 findAllByIdsInOrder를 추가했습니다. - mongodb에서 결과를 찾을 수 없는 경우, fall-back 구조로 mysql에서 검색이 일어날 수 있도록 했습니다.
- 곡의 상당수가 영어인 관계로 한국어 분석기 nori+영어 분석기 english+자동 완성의 형태로 인덱스를 구현했습니다. - 길이가 짤은 경우에는 자동완성에 2배의 가중치를 주고, 길이가 길어지면 분석기를 통한 결과에 2배의 가중치를 주도록 작성했습니다. - 가수별 곡 검색의 경우, 검색하려는 데이터의 범위가 매우 한정적이라고 생각해 따로 altas search를 적용하지는 않았습니다.
- 역시 똑같은 방식으로 SongQueryService 내 searchSongs를 수정했습니다. - ids 순서대로 결과를 받을 수 있도록 findAllByIdsInOrder를 추가했습니다. - 첫페이지인데 결과가 없는 경우 mysql like로 fall-back하도록 코드를 작성했습니다.
- 곡이 생성될 떄 mongodb에도 해당 곡이 들어갈 수 있도록 처리했습니다.
…가 저장되도록 수정 - 현재 곡 생성은 SongCollector가 담당하고 있기에 해당 과정에서 mongodb에도 데이터가 삽입되도록 수정했습니다. - 이 때 mongodb의 songid가 mysql 속 songid와 같을 수 있도록 PreparedStatement 을 사용했습니다.
- 하루에 한 번 mysql에 있는 song 중 mongofb에서 없는 song들을 추가적으로 삽입하는 동기화 로직을 작성했습니다.
- 가수별로 곡 검색의 경우 결과가 얼마 되지 않기에 mysql like로 처리할 예정입니다.
- 이 과정에서 MongoRepository 인터페이스와 2개의 구현체로 분리했습니다.
jinkonu
approved these changes
Sep 4, 2025
Collaborator
jinkonu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
대장정을 하셨군요 ...
정말 고생 많으셨고 작년보다도 훨씬 성장한 모습을 보면서 저도 많은 자극을 받았습니다.
Mongo DB와 맞닿아 있는 기술적인 부분은 블로그 글 보면서 팔로업 해볼게요!
수고 많으셨습니다 🥹🥹
src/main/java/com/projectlyrics/server/domain/artist/repository/ArtistQueryRepository.java
Outdated
Show resolved
Hide resolved
...com/projectlyrics/server/domain/artist/repository/impl/ArtistMongoCommandRepositoryImpl.java
Outdated
Show resolved
Hide resolved
src/main/java/com/projectlyrics/server/domain/artist/service/ArtistCommandService.java
Show resolved
Hide resolved
src/main/java/com/projectlyrics/server/domain/song/repository/SongMongoQueryRepository.java
Outdated
Show resolved
Hide resolved
...ain/java/com/projectlyrics/server/domain/song/repository/impl/JdbcSongCommandRepository.java
Show resolved
Hide resolved
findAllByIdsInOrder -> findAllByIdsInListOrder로 리스트의 순서를 반영한다는 의미를 명확히 하였습니다. findAllIdByIdIn->findAllByIdsIn 기존 이름이 중복되고 이상해서 수정했습니다.
- ArtistMongo를 확장해서 쓸 이유도 없고 지금은 List로만 사용하고 있기에 그에 맞게 정의 부분을 수정했습니다.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🍃 Pull Requests
⛳️ 작업한 브랜치
👷 작업한 내용
🚨 참고 사항