aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service/SphinxSearchService.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2020-06-05 11:22:31 +0300
committerGravatar Vitaly Takmazov2020-06-05 11:22:31 +0300
commit9e5c7c562f93b4156c77fbc5ebab91a245001eb3 (patch)
treea734a07ef2911482de0c6cda184b8276e8c0ce98 /src/main/java/com/juick/service/SphinxSearchService.java
parentc571ab6ad8c215cae54c17a454ec8f84b24ba1b5 (diff)
Fix sort hint
Diffstat (limited to 'src/main/java/com/juick/service/SphinxSearchService.java')
-rw-r--r--src/main/java/com/juick/service/SphinxSearchService.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/com/juick/service/SphinxSearchService.java b/src/main/java/com/juick/service/SphinxSearchService.java
index aa62ddda..4fa99c8a 100644
--- a/src/main/java/com/juick/service/SphinxSearchService.java
+++ b/src/main/java/com/juick/service/SphinxSearchService.java
@@ -47,7 +47,11 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic
return searchString.split("[^\\S\\+]+").length == 1;
}
- public String keywordBoost(String searchString) {
+ String sortHint() {
+ return "extended:@weight desc, @id desc";
+ }
+
+ String keywordBoost(String searchString) {
return isOneWord(searchString) ? String.format("%s^3", searchString) : searchString;
}
@@ -59,7 +63,7 @@ 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());
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)) {
@@ -83,7 +87,7 @@ 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", sortHint(searchString));
+ sphinxQuery.put("sort", sortHint());
if (page > 0) {
sphinxQuery.put("offset", String.valueOf(page * maxResult));
}