forked from rDrama/rDrama
fix exact searching
parent
be35a3d98d
commit
755a1ff60d
|
@ -229,9 +229,11 @@ 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("english", text)
|
||||
func.websearch_to_tsquery(regconfig, text)
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -328,9 +330,11 @@ 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("english", text)
|
||||
func.websearch_to_tsquery(regconfig, text)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
alter table comments drop column body_ts;
|
||||
alter table comments add column body_ts tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (body)::text)) STORED;
|
|
@ -459,7 +459,7 @@ CREATE TABLE public.comments (
|
|||
queened boolean NOT NULL,
|
||||
sharpened boolean NOT NULL,
|
||||
num_of_pinned_children integer NOT NULL,
|
||||
body_ts tsvector GENERATED ALWAYS AS (to_tsvector('english'::regconfig, (body)::text)) STORED,
|
||||
body_ts tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (body)::text)) STORED,
|
||||
distinguished boolean NOT NULL
|
||||
);
|
||||
|
||||
|
@ -3074,4 +3074,3 @@ ALTER TABLE ONLY public.comments
|
|||
--
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
|
|
Loading…
Reference in New Issue