aboutsummaryrefslogtreecommitdiff
path: root/juick-server-jdbc/src/main/java/com/juick/service
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server-jdbc/src/main/java/com/juick/service')
-rw-r--r--juick-server-jdbc/src/main/java/com/juick/service/SphinxSearchService.java (renamed from juick-server-jdbc/src/main/java/com/juick/service/FTSSearchServiceImpl.java)16
1 files changed, 7 insertions, 9 deletions
diff --git a/juick-server-jdbc/src/main/java/com/juick/service/FTSSearchServiceImpl.java b/juick-server-jdbc/src/main/java/com/juick/service/SphinxSearchService.java
index 8d2ffbdb..26cf3a16 100644
--- a/juick-server-jdbc/src/main/java/com/juick/service/FTSSearchServiceImpl.java
+++ b/juick-server-jdbc/src/main/java/com/juick/service/SphinxSearchService.java
@@ -31,7 +31,7 @@ import java.util.List;
@Repository
@Transactional(readOnly = true)
-public class FTSSearchServiceImpl extends BaseJdbcService implements SearchService {
+public class SphinxSearchService extends BaseJdbcService implements SearchService {
private static final int DEFAULT_MAX_RESULT = 20;
private int maxResult = DEFAULT_MAX_RESULT;
@@ -43,14 +43,13 @@ public class FTSSearchServiceImpl extends BaseJdbcService implements SearchServi
MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource()
.addValue("search", searchString)
- .addValue("before", messageIdBefore)
+ .addValue("before", messageIdBefore - 1)
.addValue("limit", maxResult);
return getNamedParameterJdbcTemplate().queryForList(
- "SELECT message_id FROM messages_txt WHERE MATCH(txt) AGAINST(:search) " +
+ "SELECT id FROM search WHERE query = ':search;limit=:limit;mode=any;sort=extended:@id desc" +
(messageIdBefore > 0 ?
- " AND message_id < :before " : StringUtils.EMPTY) +
- " ORDER BY message_id DESC LIMIT :limit",
+ ";maxid=:before" : StringUtils.EMPTY) + "'",
sqlParameterSource,
Integer.class);
}
@@ -63,14 +62,13 @@ public class FTSSearchServiceImpl extends BaseJdbcService implements SearchServi
MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource()
.addValue("search", searchString)
.addValue("userId", userId)
- .addValue("before", messageIdBefore)
+ .addValue("before", messageIdBefore - 1)
.addValue("limit", maxResult);
return getNamedParameterJdbcTemplate().queryForList(
- "SELECT messages.message_id AS message_id FROM messages INNER JOIN messages_txt ON messages_txt.message_id=messages.message_id WHERE messages.user_id = :userId AND MATCH(messages_txt.txt) AGAINST (:search) " +
+ "SELECT id FROM search WHERE query = ':search;filter=user_id,:userId;sort=extended:@id desc" +
(messageIdBefore > 0 ?
- " AND messages.message_id < :before " : StringUtils.EMPTY) +
- " ORDER BY messages.message_id DESC LIMIT :limit",
+ ";maxid=:before" : StringUtils.EMPTY) + "'",
sqlParameterSource,
Integer.class);
}