diff --git a/logstash/index-config.json b/logstash/index-config.json index bef54d8d..8283ad1e 100644 --- a/logstash/index-config.json +++ b/logstash/index-config.json @@ -112,6 +112,14 @@ "fields": { "keyword": { "type": "keyword" + }, + "ngram": { + "type": "text", + "analyzer": "ngram_analyzer" + }, + "edge_ngram": { + "type": "text", + "analyzer": "edge_ngram_analyzer" } } }, @@ -120,6 +128,14 @@ "fields": { "keyword": { "type": "keyword" + }, + "ngram": { + "type": "text", + "analyzer": "ngram_analyzer" + }, + "edge_ngram": { + "type": "text", + "analyzer": "edge_ngram_analyzer" } } }, diff --git a/src/main/java/org/example/tablenow/domain/store/controller/StoreController.java b/src/main/java/org/example/tablenow/domain/store/controller/StoreController.java index ac66751a..04c4ee93 100644 --- a/src/main/java/org/example/tablenow/domain/store/controller/StoreController.java +++ b/src/main/java/org/example/tablenow/domain/store/controller/StoreController.java @@ -64,6 +64,7 @@ public ResponseEntity deleteStore(@PathVariable Long sto } // 가게 검색 v1 (RDBMS) + @Deprecated @Operation(summary = "가게 검색 V1 (RDB)") @GetMapping("/v1/stores") public ResponseEntity> getStoresV1(@AuthenticationPrincipal AuthUser authUser, @@ -73,6 +74,7 @@ public ResponseEntity> getStoresV1(@AuthenticationP } // 가게 검색 v2 (Redis) + @Deprecated @Operation(summary = "가게 검색 V2 (Redis)") @GetMapping("/v2/stores") public ResponseEntity> getStoresV2(@AuthenticationPrincipal AuthUser authUser, diff --git a/src/main/java/org/example/tablenow/domain/store/enums/StoreSortField.java b/src/main/java/org/example/tablenow/domain/store/enums/StoreSortField.java index 2d4b6896..c33e6661 100644 --- a/src/main/java/org/example/tablenow/domain/store/enums/StoreSortField.java +++ b/src/main/java/org/example/tablenow/domain/store/enums/StoreSortField.java @@ -56,7 +56,7 @@ public OrderSpecifier toOrderSpecifier(PathBuilder path, boolean isAsc) { public static StoreSortField from(String property) { for (StoreSortField field : values()) { - if (field.property.equals(property)) { + if (field.property.contains(property)) { return field; } } @@ -65,7 +65,7 @@ public static StoreSortField from(String property) { public static String fromString(String property) { for (StoreSortField field : values()) { - if (field.property.equals(property)) { + if (field.property.contains(property)) { return field.property; } } diff --git a/src/main/java/org/example/tablenow/domain/store/repository/StoreElasticRepository.java b/src/main/java/org/example/tablenow/domain/store/repository/StoreElasticRepository.java index d4dea67d..4fcf07e9 100644 --- a/src/main/java/org/example/tablenow/domain/store/repository/StoreElasticRepository.java +++ b/src/main/java/org/example/tablenow/domain/store/repository/StoreElasticRepository.java @@ -122,7 +122,11 @@ private void whereKeywordContains(String keyword, BoolQuery.Builder boolQueryBui "name.edge_ngram^1.5", "description^2.5", "description.keyword^3", - "address^2.5", "address.keyword^3") + "description.ngram^1.5", + "description.edge_ngram^1.5", + "address^2.5", "address.keyword^3", + "address.ngram^1.5", + "address.edge_ngram^1.5") ) ); } diff --git a/src/main/java/org/example/tablenow/domain/store/service/StoreSearchService.java b/src/main/java/org/example/tablenow/domain/store/service/StoreSearchService.java index f551bf12..76bc3e6c 100644 --- a/src/main/java/org/example/tablenow/domain/store/service/StoreSearchService.java +++ b/src/main/java/org/example/tablenow/domain/store/service/StoreSearchService.java @@ -87,7 +87,11 @@ public void evictSearchCacheByStoreId(Long storeId) { private Pageable resolvePageable(int page, int size, String sort, String direction) { try { - Sort sortOption = Sort.by(Sort.Direction.fromString(direction), StoreSortField.fromString(sort)); + String sortProperty = StoreSortField.fromString(sort); + if (sortProperty.contains("name")) { + sortProperty += ".keyword"; + } + Sort sortOption = Sort.by(Sort.Direction.fromString(direction.toUpperCase()), sortProperty); return PageRequest.of(page - 1, size, sortOption); } catch (IllegalArgumentException e) { throw new HandledException(ErrorCode.INVALID_ORDER_VALUE); diff --git a/src/main/resources/elastic/store-mapping.json b/src/main/resources/elastic/store-mapping.json index 23c2f7c4..e036fa0c 100644 --- a/src/main/resources/elastic/store-mapping.json +++ b/src/main/resources/elastic/store-mapping.json @@ -24,6 +24,14 @@ "fields": { "keyword": { "type": "keyword" + }, + "ngram": { + "type": "text", + "analyzer": "ngram_analyzer" + }, + "edge_ngram": { + "type": "text", + "analyzer": "edge_ngram_analyzer" } } }, @@ -32,6 +40,14 @@ "fields": { "keyword": { "type": "keyword" + }, + "ngram": { + "type": "text", + "analyzer": "ngram_analyzer" + }, + "edge_ngram": { + "type": "text", + "analyzer": "edge_ngram_analyzer" } } },