Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error when searching notes - EXO-65101 - Meeds-io/meeds#1038 #707

Merged
merged 1 commit into from
Jul 27, 2023
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 @@ -131,13 +131,7 @@ private String buildQueryStatement(Set<String> calendarOwnersOfUser,
long limit) {
term = removeSpecialCharacters(term);
term = StringUtils.isBlank(term) ? "*:*" : term;
List<String> termsQuery = Arrays.stream(term.split(" ")).filter(StringUtils::isNotBlank).map(word -> {
word = word.trim();
if (word.length() > 5) {
word = word + "~1";
}
return word;
}).collect(Collectors.toList());
List<String> termsQuery = Arrays.stream(term.split(" ")).filter(StringUtils::isNotBlank).map(word -> "*" + word + "*").collect(Collectors.toList());
Map<String, List<String>> metadataFilters = buildMetadataFilter(isFavorites, userId);
String metadataQuery = buildMetadataQueryStatement(metadataFilters);
String termQuery = StringUtils.join(termsQuery, " AND ");
Expand Down Expand Up @@ -203,12 +197,6 @@ protected List<SearchResult> buildWikiResult(String jsonResponse) {
String pageName = (String) hitSource.get("name");
String attachmentName = null;

// Result can be an attachment
if (((JSONObject) jsonHit).get("_type").equals("wiki-attachment")) {
pageName = (String) hitSource.get("pageName");
attachmentName = (String) hitSource.get("name");
}

// Get the excerpt
JSONObject hitHighlight = (JSONObject) ((JSONObject) jsonHit).get("highlight");
StringBuilder excerpt = new StringBuilder();
Expand Down
10 changes: 1 addition & 9 deletions notes-service/src/main/resources/notes-search-query.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
}
}
],
"should": {
"match_phrase": {
"attachment.content": {
"query": "@term@",
"boost": 5
}
}
},
"must":{
"query_string":{
"fields": ["name","title^5","content","comment","attachment.content"],
Expand Down Expand Up @@ -50,4 +42,4 @@
}
}
}
}
}