-
Notifications
You must be signed in to change notification settings - Fork 4
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
카페 검색 기능 개발 #443
Merged
Merged
카페 검색 기능 개발 #443
Changes from 5 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f0d02b2
refactor:LikedCafeThumbnail dto명 변경
hum02 dd80429
chore:QueryDsl 의존성 및 환경설정(#433)
hum02 b4e29c1
feat:카페 동적 쿼리 repository구현(#433)
hum02 f86685e
feat:카페 검색 API 구현(#433)
hum02 1d74670
refactor:가독성 위한 개행
hum02 d294873
feat:검색 기준마다의 검색어로 카페 조회 기능(#433)
hum02 9e22d9f
refactor:cafeThumbnailResponse 메서드가 Cafe를 인자로 받도록 수정
hum02 dfb99f9
refactor:불필요한 서브쿼리 삭제(#433)
hum02 5f80dd5
refactor:querydsl 메서드에 distinct 추가(#433)
hum02 c18154a
refactor:불필요한 join과 distinct삭제
hum02 00185fa
임시 커밋 push 안됨
hum02 20c4c88
refactor:검색 기능 가독성 개선(#433)
hum02 2fab8e0
refactor:불필요한 파일 삭제
hum02 806b0f8
refactor:menu에 따른 분기처리 가독성 개선
hum02 c0f46c5
feat:검색 기능에 fulltext search 적용(#433)
hum02 022b301
Merge branch 'dev' into feat/433-search
hum02 3ad24e4
refactor:fulltext 인덱스 설정 sql문 컨벤션 수정(#433)
hum02 e8d3325
refactor:match against문 querydsl 가독성 개선(#433)
hum02 595cbba
Merge branch 'dev' into feat/433-search
hum02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
19 changes: 19 additions & 0 deletions
19
server/src/main/java/com/project/yozmcafe/domain/cafe/CustomFunctionContributor.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.project.yozmcafe.domain.cafe; | ||
|
||
import org.hibernate.boot.model.FunctionContributions; | ||
import org.hibernate.boot.model.FunctionContributor; | ||
|
||
import static org.hibernate.type.StandardBasicTypes.DOUBLE; | ||
|
||
public class CustomFunctionContributor implements FunctionContributor { | ||
|
||
private static final String FUNCTION_NAME = "match_against"; | ||
private static final String FUNCTION_PATTERN = "match (?1) against (?2 in boolean mode)"; | ||
|
||
@Override | ||
public void contributeFunctions(final FunctionContributions functionContributions) { | ||
functionContributions.getFunctionRegistry() | ||
.registerPattern(FUNCTION_NAME, FUNCTION_PATTERN, | ||
functionContributions.getTypeConfiguration().getBasicTypeRegistry().resolve(DOUBLE)); | ||
} | ||
} |
This file contains 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
1 change: 1 addition & 0 deletions
1
server/src/main/resources/META-INF/services/org.hibernate.boot.model.FunctionContributor
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.project.yozmcafe.domain.cafe.CustomFunctionContributor | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 함수를 등록하려면 이 부분이 필요한 건가요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
5 changes: 5 additions & 0 deletions
5
server/src/main/resources/db/migration/V20230925125500__full_text_idx.sql
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ALTER TABLE cafe ADD FULLTEXT INDEX cafe_name_idx (name) WITH PARSER NGRAM; | ||
|
||
ALTER TABLE cafe ADD FULLTEXT INDEX address_idx (address) WITH PARSER NGRAM; | ||
|
||
ALTER TABLE menu ADD FULLTEXT INDEX menu_name_idx (name) WITH PARSER NGRAM; |
This file contains 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
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.
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.
RepositoryImpl에서
match_against
라는 것을 봤을 때 이게 뭐지?? 싶었는데 패턴 매칭으로 여기서 함수를 정의하고 있었군요.match against 문을 바로 쓰지 않고 함수화하는 이유가 궁금합니다.
어떤 이점이 있나요??
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.
저도 가능하면 특화구문을 최소한의 의존성으로 사용하고 싶어요!
이런 식으로 match against문을 바로 쓰는 것을 생각하신 게 맞나요?
이렇게 사용할 시 hql이 이런 특화 구문을 지원해주지 않아 hibernate에서 parsing할 때 exception이 발생합니다 ㅜ.
그렇다고 native query사용을 위해 entityManager를 직접 사용하면 querydsl을 통한 동적쿼리의 의미가 없어지는 것 같고....
때문에 함수 등록을 하는 방법을 택했습니다! 다른 방법이 있을까요?
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.
query dsl은 말 그대로 DSL로 편하게 동적 쿼리를 작성하기 위함이고 native query를 사용하는 것은 피할 수 없다고 생각해요.
필요하면 JDBC Template을 쓰거나, Entity Manager로 날리거나 하는 것이 당연하다고 생각합니다!
근데 만약 여기서 Entity Manager를 사용하면 좀 더 추상객체(Entity Manager)의 의존만으로 처리할 수 있지 않나 해서 남겼어요!
어떤 장점 때문에 했는지 궁금해서요.
native query가 필요할 때마다 native query가 아닌 Query DSL로 하실 것인가요??
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.
아 Entity Manager로 변경하라는 뜻은 아닙니다!
지금 그대로도 좋아요!! 단순 궁금증입니다.
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.
querydsl의 where에 native쿼리가 들어가야 처음 querydsl을 쓸 때 의도했던 대로
하나의 쿼리 template으로 동적인 쿼리가 가능하다 생각해요!
Entity Manager를 쓰면서 이를 querydsl에 적용하려면 EntityManager의 쿼리 형식을 booleanExpression으로 바꿔야 하는 데 그게 가능한지 모르겠네요...