-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- findDynamicField -> findDynamicFieldByCenterId 네이밍 수정 - recruitboard 조회 쿼리문 형식 수정 - elastic search 활성화 확인 어노테이션 생성 및 적용 - 검색 컨트롤러 else 제거 - elastic search 저장 scheduler 로직 순서 수정 (활성화 체크 우선) -
- Loading branch information
1 parent
b9a1f57
commit 9cb0dbc
Showing
13 changed files
with
83 additions
and
39 deletions.
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
18 changes: 18 additions & 0 deletions
18
src/main/java/com/somemore/domains/search/annotation/ConditionalOnElasticSearchEnabled.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,18 @@ | ||
package com.somemore.domains.search.annotation; | ||
|
||
import org.springframework.context.annotation.Conditional; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Documented | ||
@Conditional(OnElasticSearchEnabledCondition.class) | ||
public @interface ConditionalOnElasticSearchEnabled { | ||
String propertyName() default "elastic.search.enabled"; | ||
String havingValue() default "true"; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/somemore/domains/search/annotation/OnElasticSearchEnabledCondition.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,20 @@ | ||
package com.somemore.domains.search.annotation; | ||
|
||
import org.springframework.context.annotation.Condition; | ||
import org.springframework.context.annotation.ConditionContext; | ||
import org.springframework.core.type.AnnotatedTypeMetadata; | ||
import org.springframework.util.MultiValueMap; | ||
|
||
public class OnElasticSearchEnabledCondition implements Condition { | ||
|
||
@Override | ||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) { | ||
MultiValueMap<String, Object> attrs = metadata.getAllAnnotationAttributes( | ||
ConditionalOnElasticSearchEnabled.class.getName()); | ||
String propertyName = (String) attrs.getFirst("propertyName"); | ||
String havingValue = (String) attrs.getFirst("havingValue"); | ||
|
||
String propertyValue = context.getEnvironment().getProperty(propertyName); | ||
return havingValue.equals(propertyValue); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/main/java/com/somemore/domains/search/config/ElasticsearchConfig.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
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
14 changes: 11 additions & 3 deletions
14
src/main/java/com/somemore/domains/search/repository/CommunityBoardDocumentRepository.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 |
---|---|---|
@@ -1,15 +1,23 @@ | ||
package com.somemore.domains.search.repository; | ||
|
||
import com.somemore.domains.search.annotation.ConditionalOnElasticSearchEnabled; | ||
import com.somemore.domains.search.domain.CommunityBoardDocument; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.data.elasticsearch.annotations.Query; | ||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; | ||
|
||
import java.util.List; | ||
|
||
@ConditionalOnProperty(name = "elastic.search.enabled", havingValue = "true") | ||
@ConditionalOnElasticSearchEnabled | ||
public interface CommunityBoardDocumentRepository extends ElasticsearchRepository<CommunityBoardDocument, Long> { | ||
List<CommunityBoardDocument> findAll(); | ||
@Query("{\"multi_match\": {\"query\": \"?0\", \"fields\": [\"title^3\", \"content^2\", \"writerNickname\"], \"fuzziness\": \"AUTO\"}}") | ||
@Query(""" | ||
{ | ||
"multi_match": { | ||
"query": "?0", | ||
"fields": ["title^3", "content^2", "writerNickname"], | ||
"fuzziness": "AUTO" | ||
} | ||
} | ||
""") | ||
List<CommunityBoardDocument> findDocumentsByTitleOrContentOrNicknameContaining(String keyword); | ||
} |
4 changes: 2 additions & 2 deletions
4
src/main/java/com/somemore/domains/search/repository/RecruitBoardDocumentRepository.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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package com.somemore.domains.search.repository; | ||
|
||
import com.somemore.domains.search.annotation.ConditionalOnElasticSearchEnabled; | ||
import com.somemore.domains.search.domain.RecruitBoardDocument; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; | ||
|
||
@ConditionalOnProperty(name = "elastic.search.enabled", havingValue = "true") | ||
@ConditionalOnElasticSearchEnabled | ||
public interface RecruitBoardDocumentRepository extends ElasticsearchRepository<RecruitBoardDocument, Long> { | ||
} |
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
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