From 8b984a510eb1aad27ccde64a6ccfc5eea12aed1b Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 28 Feb 2024 22:02:08 +0200 Subject: [PATCH] Revert "fix exact searching" This reverts commit 755a1ff60dbc326a1ae5f95e70bbcf192e972785. --- files/routes/search.py | 8 ++------ migrations/20240228-fix-exact-searching.sql | 3 --- schema.sql | 5 ++--- 3 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 migrations/20240228-fix-exact-searching.sql diff --git a/files/routes/search.py b/files/routes/search.py index fd157ae2c..ba227c3d2 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -224,11 +224,9 @@ def searchcomments(v): if 'q' in criteria: text = criteria['full_text'] - if '"' in text: regconfig = "simple" - else: regconfig = "english" comments = comments.filter( Comment.body_ts.bool_op("@@")( - func.websearch_to_tsquery(regconfig, text) + func.websearch_to_tsquery("english", text) ) ) @@ -325,11 +323,9 @@ def searchmessages(v): if 'q' in criteria: text = criteria['full_text'] - if '"' in text: regconfig = "simple" - else: regconfig = "english" comments = comments.filter( Comment.body_ts.bool_op("@@")( - func.websearch_to_tsquery(regconfig, text) + func.websearch_to_tsquery("english", text) ) ) diff --git a/migrations/20240228-fix-exact-searching.sql b/migrations/20240228-fix-exact-searching.sql deleted file mode 100644 index e69833509..000000000 --- a/migrations/20240228-fix-exact-searching.sql +++ /dev/null @@ -1,3 +0,0 @@ -alter table comments add column body_ts2 tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (body)::text)) STORED; -alter table comments drop column body_ts; -alter table comments rename column body_ts2 to body_ts; diff --git a/schema.sql b/schema.sql index 55323e409..6802ab9eb 100644 --- a/schema.sql +++ b/schema.sql @@ -459,8 +459,8 @@ CREATE TABLE public.comments ( queened boolean NOT NULL, sharpened boolean NOT NULL, num_of_pinned_children integer NOT NULL, - distinguished boolean NOT NULL, - body_ts tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (body)::text)) STORED + body_ts tsvector GENERATED ALWAYS AS (to_tsvector('english'::regconfig, (body)::text)) STORED, + distinguished boolean NOT NULL ); @@ -3067,4 +3067,3 @@ ALTER TABLE ONLY public.comments -- -- PostgreSQL database dump complete -- -