aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2020-06-05 11:59:09 +0300
committerGravatar Vitaly Takmazov2020-06-05 11:59:09 +0300
commit097066de58c04965c50da20db35aa5d81c54d7e7 (patch)
treeea89b04f5eeea10b525c0b80d13a598c37358750 /src/main/java/com/juick
parent9297e1dc40bfa9e05fc598403f224270f10c9154 (diff)
Revert "Use best-match ranker for one word queries"
This reverts commit c571ab6ad8c215cae54c17a454ec8f84b24ba1b5.
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/service/SphinxSearchService.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main/java/com/juick/service/SphinxSearchService.java b/src/main/java/com/juick/service/SphinxSearchService.java
index aa62ddda..1553e22f 100644
--- a/src/main/java/com/juick/service/SphinxSearchService.java
+++ b/src/main/java/com/juick/service/SphinxSearchService.java
@@ -43,12 +43,12 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic
@Inject
UserService userService;
- boolean isOneWord(String searchString) {
- return searchString.split("[^\\S\\+]+").length == 1;
+ public String sortHint(String searchString) {
+ return "extended:@weight desc, @id desc";
}
-
public String keywordBoost(String searchString) {
- return isOneWord(searchString) ? String.format("%s^3", searchString) : searchString;
+ boolean isOneWord = searchString.split("[^\\S\\+]+").length == 1;
+ return isOneWord ? String.format("%s^3", searchString) : searchString;
}
@Override
@@ -59,12 +59,9 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic
Map<String, String> sphinxQuery = new HashMap<>();
sphinxQuery.put("limit", String.valueOf(maxResult));
sphinxQuery.put("mode", "any");
- sphinxQuery.put("sort", "extended:@weight desc, @id desc");
+ sphinxQuery.put("sort", sortHint(searchString));
String usersFilter = userService.getUserBLUsers(visitor.getUid()).stream().map(u -> String.valueOf(u.getUid())).collect(Collectors.joining(","));
sphinxQuery.put("!filter", "user_id," + usersFilter);
- if (isOneWord(searchString)) {
- sphinxQuery.put("ranker", "bm25");
- }
if (page > 0) {
sphinxQuery.put("offset", String.valueOf(page * maxResult));
}