Refactor full-text search to get rid of tsvector columns.
Refactor full-text search on several tables (comments, dmails, forum_posts, forum_topics, notes, and wiki_pages) to use to_tsvector expression indexes instead of dedicated tsvector columns. This way full-text search works the same way across all tables. API changes: * Changed /wiki_pages.json?search[body_matches] to match against only the body. Before `body_matches` matched against both the title and the body. * Added /wiki_pages.json?search[title_or_body_matches] to match against both the title and the body. * Fixed /dmails.json?search[message_matches] to match against both the title and body when doing a wildcard search. Before a wildcard search only matched against the body. * Added /dmails.json?search[body_matches] to match against only the dmail body.
This commit is contained in:
@@ -3281,6 +3281,13 @@ CREATE UNIQUE INDEX index_comment_votes_on_user_id_and_comment_id ON public.comm
|
||||
CREATE INDEX index_comments_on_body_index ON public.comments USING gin (body_index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_comments_on_body_tsvector; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_comments_on_body_tsvector ON public.comments USING gin (to_tsvector('english'::regconfig, body));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_comments_on_created_at; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -3379,6 +3386,13 @@ CREATE INDEX index_dmails_on_message_index ON public.dmails USING gin (message_i
|
||||
CREATE INDEX index_dmails_on_owner_id ON public.dmails USING btree (owner_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_dmails_on_title_and_body_tsvector; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_dmails_on_title_and_body_tsvector ON public.dmails USING gin (((to_tsvector('english'::regconfig, title) || to_tsvector('english'::regconfig, body))));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_dtext_links_on_link_target; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -3498,6 +3512,13 @@ CREATE INDEX index_forum_post_votes_on_forum_post_id ON public.forum_post_votes
|
||||
CREATE UNIQUE INDEX index_forum_post_votes_on_forum_post_id_and_creator_id ON public.forum_post_votes USING btree (forum_post_id, creator_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_forum_posts_on_body_tsvector; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_forum_posts_on_body_tsvector ON public.forum_posts USING gin (to_tsvector('english'::regconfig, body));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_forum_posts_on_creator_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -3568,6 +3589,13 @@ CREATE INDEX index_forum_topics_on_is_sticky_and_updated_at ON public.forum_topi
|
||||
CREATE INDEX index_forum_topics_on_text_index ON public.forum_topics USING gin (text_index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_forum_topics_on_title_tsvector; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_forum_topics_on_title_tsvector ON public.forum_topics USING gin (to_tsvector('english'::regconfig, (title)::text));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_forum_topics_on_updated_at; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -3855,6 +3883,13 @@ CREATE INDEX index_note_versions_on_updater_ip_addr ON public.note_versions USIN
|
||||
CREATE INDEX index_notes_on_body_index ON public.notes USING gin (body_index);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_notes_on_body_tsvector; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_notes_on_body_tsvector ON public.notes USING gin (to_tsvector('english'::regconfig, body));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_notes_on_post_id; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -4675,6 +4710,13 @@ CREATE INDEX index_wiki_pages_on_other_names ON public.wiki_pages USING gin (oth
|
||||
CREATE UNIQUE INDEX index_wiki_pages_on_title ON public.wiki_pages USING btree (title);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_wiki_pages_on_title_and_body_tsvector; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE INDEX index_wiki_pages_on_title_and_body_tsvector ON public.wiki_pages USING gin (((to_tsvector('english'::regconfig, (title)::text) || to_tsvector('english'::regconfig, body))));
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_wiki_pages_on_title_pattern; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
@@ -4996,6 +5038,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||
('20211010181657'),
|
||||
('20211011044400'),
|
||||
('20211013011619'),
|
||||
('20211014063943');
|
||||
('20211014063943'),
|
||||
('20211015223510');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user