Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions logstash/index-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@
"fields": {
"keyword": {
"type": "keyword"
},
"ngram": {
"type": "text",
"analyzer": "ngram_analyzer"
},
"edge_ngram": {
"type": "text",
"analyzer": "edge_ngram_analyzer"
}
}
},
Expand All @@ -120,6 +128,14 @@
"fields": {
"keyword": {
"type": "keyword"
},
"ngram": {
"type": "text",
"analyzer": "ngram_analyzer"
},
"edge_ngram": {
"type": "text",
"analyzer": "edge_ngram_analyzer"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public ResponseEntity<StoreDeleteResponseDto> deleteStore(@PathVariable Long sto
}

// 가게 검색 v1 (RDBMS)
@Deprecated
@Operation(summary = "가게 검색 V1 (RDB)")
@GetMapping("/v1/stores")
public ResponseEntity<Page<StoreSearchResponseDto>> getStoresV1(@AuthenticationPrincipal AuthUser authUser,
Expand All @@ -73,6 +74,7 @@ public ResponseEntity<Page<StoreSearchResponseDto>> getStoresV1(@AuthenticationP
}

// 가게 검색 v2 (Redis)
@Deprecated
@Operation(summary = "가게 검색 V2 (Redis)")
@GetMapping("/v2/stores")
public ResponseEntity<Page<StoreSearchResponseDto>> getStoresV2(@AuthenticationPrincipal AuthUser authUser,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions src/main/resources/elastic/store-mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
"fields": {
"keyword": {
"type": "keyword"
},
"ngram": {
"type": "text",
"analyzer": "ngram_analyzer"
},
"edge_ngram": {
"type": "text",
"analyzer": "edge_ngram_analyzer"
}
}
},
Expand All @@ -32,6 +40,14 @@
"fields": {
"keyword": {
"type": "keyword"
},
"ngram": {
"type": "text",
"analyzer": "ngram_analyzer"
},
"edge_ngram": {
"type": "text",
"analyzer": "edge_ngram_analyzer"
}
}
},
Expand Down