aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2020-06-05 11:30:38 +0300
committerGravatar Vitaly Takmazov2020-06-05 11:30:38 +0300
commitbbb06da27162385d147ef0ff78d787a4b2de6762 (patch)
tree58346a76fc5203ad42fe2894fee6abe6cbe0041e /src/main/java/com/juick/service
parent9e5c7c562f93b4156c77fbc5ebab91a245001eb3 (diff)
Use default search mode for keywords
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/SphinxSearchService.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/com/juick/service/SphinxSearchService.java b/src/main/java/com/juick/service/SphinxSearchService.java
index 4fa99c8a..0e5634cc 100644
--- a/src/main/java/com/juick/service/SphinxSearchService.java
+++ b/src/main/java/com/juick/service/SphinxSearchService.java
@@ -51,6 +51,10 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic
return "extended:@weight desc, @id desc";
}
+ String modeSwitch(String searchString) {
+ return isOneWord(searchString) ? "all": "any";
+ }
+
String keywordBoost(String searchString) {
return isOneWord(searchString) ? String.format("%s^3", searchString) : searchString;
}
@@ -62,7 +66,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("mode", modeSwitch(searchString));
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);
@@ -86,7 +90,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("mode", modeSwitch(searchString));
sphinxQuery.put("sort", sortHint());
if (page > 0) {
sphinxQuery.put("offset", String.valueOf(page * maxResult));