diff options
author | Vitaly Takmazov | 2020-10-20 23:43:41 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2020-10-20 23:43:41 +0300 |
commit | ddfaa389a00fc198a35f8d505b24d9eb50ff75a5 (patch) | |
tree | c8d6efef9d4e984d6f85c912d85d8f5e85c3326d /src/main/java/com/juick/service/SphinxSearchService.java | |
parent | 7feb5789d1eedd9e3b0ec88c5a8209e116e2b28e (diff) |
Revert "Append * to keyword search"
This reverts commit 85c5c69ffb5a14258eafb4c67c550f6018b3c621.
Diffstat (limited to 'src/main/java/com/juick/service/SphinxSearchService.java')
-rw-r--r-- | src/main/java/com/juick/service/SphinxSearchService.java | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/main/java/com/juick/service/SphinxSearchService.java b/src/main/java/com/juick/service/SphinxSearchService.java index e907515d..302f10de 100644 --- a/src/main/java/com/juick/service/SphinxSearchService.java +++ b/src/main/java/com/juick/service/SphinxSearchService.java @@ -43,19 +43,13 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic @Inject UserService userService; - String sortHint(String searchString) { + public String sortHint(String searchString) { boolean isOneWord = searchString.split("[^\\S\\+]+").length == 1; return isOneWord ? "extended:@id desc" : "extended:@weight desc, @id desc"; } - String searchTerm(String searchString, boolean exact) { - String prefix = exact ? "*" : ""; - return String.format("%s%s", prefix, searchString); - } - @Override - public List<Integer> searchInAllMessages(User visitor, final String searchString, final int page, - final boolean exact) { + public List<Integer> searchInAllMessages(User visitor, final String searchString, final int page) { if (StringUtils.isBlank(searchString)) return Collections.emptyList(); @@ -70,14 +64,13 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic } return getJdbcTemplate().queryForList( - String.format("SELECT id FROM search WHERE query = '%s;%s'", searchTerm(searchString, exact), + String.format("SELECT id FROM search WHERE query = '%s;%s'", searchString, sphinxQuery.entrySet().stream().map(Object::toString) .collect(Collectors.joining(";"))), Integer.class); } @Override - public List<Integer> searchByStringAndUser(User visitor, final String searchString, final int userId, int page, - final boolean exact) { + public List<Integer> searchByStringAndUser(User visitor, final String searchString, final int userId, int page) { if (StringUtils.isBlank(searchString)) return Collections.emptyList(); @@ -89,7 +82,7 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic sphinxQuery.put("offset", String.valueOf(page * maxResult)); } return getJdbcTemplate().queryForList( - String.format("SELECT id FROM search WHERE query = '%s;%s;filter=user_id,%d'", searchTerm(searchString, exact), + String.format("SELECT id FROM search WHERE query = '%s;%s;filter=user_id,%d'", searchString, sphinxQuery.entrySet().stream().map(Object::toString) .collect(Collectors.joining(";")), userId), Integer.class); } |