aboutsummaryrefslogtreecommitdiffstats
path: root/db/schema.sql
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2020-07-29 09:03:56 +0100
committerMatthew Somerville <matthew@mysociety.org>2020-07-31 12:33:38 +0100
commitbd42d6a1fcb6c8e6d89413e0ee22617625d95bad (patch)
tree2bdbeff779e44d14aa2409f9660ab3c91c9a8377 /db/schema.sql
parent34dd7c253d337ea922049390dc6ba44b8686e516 (diff)
Add database index for full text search.
Diffstat (limited to 'db/schema.sql')
-rw-r--r--db/schema.sql12
1 files changed, 12 insertions, 0 deletions
diff --git a/db/schema.sql b/db/schema.sql
index ed21aded6..f198a287b 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -246,6 +246,12 @@ create index problem_user_id_idx on problem ( user_id );
create index problem_external_body_idx on problem(lower(external_body));
create index problem_radians_latitude_longitude_idx on problem(radians(latitude), radians(longitude));
create index problem_bodies_str_array_idx on problem USING gin(regexp_split_to_array(bodies_str, ','));
+create index problem_fulltext_idx on problem USING GIN(
+ to_tsvector(
+ 'english',
+ translate(id || ' ' || coalesce(external_id,'') || ' ' || coalesce(bodies_str,'') || ' ' || name || ' ' || title || ' ' || detail, '/.', ' ')
+ )
+);
create table questionnaire (
id serial not null primary key,
@@ -354,6 +360,12 @@ create table comment (
create index comment_user_id_idx on comment(user_id);
create index comment_problem_id_idx on comment(problem_id);
create index comment_problem_id_created_idx on comment(problem_id, created);
+create index comment_fulltext_idx on comment USING GIN(
+ to_tsvector(
+ 'english',
+ translate(id || ' ' || problem_id || ' ' || coalesce(name,'') || ' ' || text, '/.', ' ')
+ )
+);
-- Tokens for confirmations
create table token (