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
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,21 @@ private String createShouldClauses(String searchTerm, List<String> userKeywords)
List<String> clauses = new ArrayList<>();

if (StringUtils.hasText(searchTerm)) {
clauses.add("{text: {query: '" + searchTerm + "', path: 'name', score: {boost: {value: 5}}, fuzzy: {maxEdits: 2}}}");
clauses.add("{text: {query: '" + searchTerm + "', path: 'name', score: {boost: {value: 5}}, fuzzy: {maxEdits: 1}}}");
clauses.add("{text: {query: '" + searchTerm + "', path: 'name', score: {boost: {value: 4.5}}, fuzzy: {maxEdits: 2}}}");

clauses.add("{text: {query: '" + searchTerm + "', path: 'hashtags', score: {boost: {value: 4}}, fuzzy: {maxEdits: 1}}}");
clauses.add("{text: {query: '" + searchTerm + "', path: 'address.state', score: {boost: {value: 3}}, fuzzy: {maxEdits: 1}}}");
clauses.add("{text: {query: '" + searchTerm + "', path: 'address.city', score: {boost: {value: 2}}}}");
clauses.add("{text: {query: '" + searchTerm + "', path: 'intro', score: {boost: {value: 2}}}}");

clauses.add("{text: {query: '" + searchTerm + "', path: 'address.city', score: {boost: {value: 2.5}}}}");
clauses.add("{text: {query: '" + searchTerm + "', path: 'intro', score: {boost: {value: 2.5}}}}");

//clauses.add("{regex: {query: '" + searchTerm + "', path: 'name', allowAnalyzedField: true, score: {boost: {value: 3.5}}}}");
clauses.add("{regex: {query: '" + searchTerm + ".*', path: 'name', allowAnalyzedField: true, score: {boost: {value: 4}}}}");
}

if (userKeywords != null && !userKeywords.isEmpty()) {
for (String keyword : userKeywords) {
if (StringUtils.hasText(keyword)) {
clauses.add("{text: {query: '" + keyword + "', path: 'hashtags', score: {boost: {value: 2.5}}}}");
clauses.add("{text: {query: '" + keyword + "', path: 'hashtags', score: {boost: {value: 2}}}}");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Page<CampListResponseDto> getMatchedCampsByKeywords(

// 검색어 자동완성
public List<String> getAutocompleteResults(String word) {
if (!StringUtils.hasText(word) || word.length() < 3) {
if (!StringUtils.hasText(word) || word.length() < 2) {
return new ArrayList<>();
}
return mongoSearchClient.getAutocompleteResults(word);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class SecurityPath {
"/api/users/check-duplicate",
"/",
"/api/mongo/camps/search",
"/api/mongo/camps/autocomplete",
"/api/camps/*/available",
"/api/camps/*"
};
Expand All @@ -26,7 +27,10 @@ public class SecurityPath {
"/api/logout",
"/api/keywords",
"/api/keywords/me",
"/api/camps/bookmarked"
"/api/camps/bookmarked",
"/api/camps/reviews/*",
"/api/camps/*/reviews",
"/api/camps/*/reviews/*"
};

// hasRole("ADMIN")
Expand Down
Loading