aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-02-03 23:52:54 +0300
committerGravatar Vitaly Takmazov2023-02-03 23:52:54 +0300
commitb5932feefae1c371c062db09e8424f2f08f2cada (patch)
treeac573a22d185eaf873a187c3b71f0edcbc62831a /src
parentce3a0002bec63ff1f01730d6b71ed4f213cceef3 (diff)
PostgresSearchService: limit search results in code to force query use GIN
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/service/PostgresSearchService.java11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/main/java/com/juick/service/PostgresSearchService.java b/src/main/java/com/juick/service/PostgresSearchService.java
index 2493a45e..79986670 100644
--- a/src/main/java/com/juick/service/PostgresSearchService.java
+++ b/src/main/java/com/juick/service/PostgresSearchService.java
@@ -30,6 +30,7 @@ import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
+import java.util.stream.Collectors;
/**
* Created by aalexeev on 11/18/16.
@@ -85,17 +86,13 @@ public class PostgresSearchService extends BaseJdbcService implements SearchServ
"""
ORDER BY
"""
- + (isOneWord ? "message_id DESC" : "ts_rank_cd(v, q) DESC, message_id DESC") +
- """
- LIMIT :limit OFFSET :offset
- """;
+ + (isOneWord ? "message_id DESC" : "ts_rank_cd(v, q) DESC, message_id DESC");
return getNamedParameterJdbcTemplate().queryForList(sql,
new MapSqlParameterSource()
.addValue("query", escapeQuery(searchString))
.addValue("user_id", userId)
- .addValue("filter", usersFilter)
- .addValue("limit", maxResult)
- .addValue("offset", offset), Integer.class);
+ .addValue("filter", usersFilter), Integer.class).stream()
+ .skip(offset).limit(maxResult).collect(Collectors.toList());
}
@Override