Skip to content

Commit

Permalink
[refactor] 검색 시 가게 ID만 가져오도록 변경
Browse files Browse the repository at this point in the history
- NativeQuery 빌드 시 withSourceFilter()를 추가해 restaurantId 필드만 포함되도록 설정
  • Loading branch information
jcw1031 committed Aug 28, 2024
1 parent f078f93 commit a5c1830
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.data.elasticsearch.client.elc.NativeQuery;
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
import org.springframework.data.elasticsearch.core.SearchHits;
import org.springframework.data.elasticsearch.core.query.FetchSourceFilter;
import org.springframework.stereotype.Service;
import woowa.team4.bff.interfaces.SearchService;
import woowa.team4.bff.search.document.RestaurantMenusDocument;
Expand Down Expand Up @@ -39,6 +40,7 @@ private NativeQuery buildNativeQuery(String keyword, String deliveryLocation) {
.query(nestedQuery -> nestedQuery.match(match -> match.field("menus.menuName").query(keyword))))
)))
.withSort(sort -> sort.score(score -> score.order(SortOrder.Desc)))
.withSourceFilter(FetchSourceFilter.of(new String[]{"restaurantId"}, null))
.withPageable(Pageable.ofSize(DEFAULT_MAX_SIZE))
.build();
}
Expand Down

0 comments on commit a5c1830

Please sign in to comment.