refactor: use trigram search index instead of full text search (#3900)
Co-authored-by: Balu Babu <balub997@gmail.com>
This commit is contained in:
@@ -1,17 +1,22 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE
|
||||
-- This is a custom migration file which is not generated by Prisma.
|
||||
-- The aim of this migration is to add text search indices to the TeamCollection and TeamRequest tables.
|
||||
|
||||
-- Create Extension
|
||||
CREATE EXTENSION IF NOT EXISTS pg_trgm;
|
||||
|
||||
-- Create GIN Trigram Index for Team Collection title
|
||||
CREATE INDEX
|
||||
"TeamCollection_title_trgm_idx"
|
||||
ON
|
||||
"TeamCollection"
|
||||
ADD
|
||||
titleSearch tsvector GENERATED ALWAYS AS (to_tsvector('english', title)) STORED;
|
||||
USING
|
||||
GIN (title gin_trgm_ops);
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE
|
||||
-- Create GIN Trigram Index for Team Collection title
|
||||
CREATE INDEX
|
||||
"TeamRequest_title_trgm_idx"
|
||||
ON
|
||||
"TeamRequest"
|
||||
ADD
|
||||
titleSearch tsvector GENERATED ALWAYS AS (to_tsvector('english', title)) STORED;
|
||||
USING
|
||||
GIN (title gin_trgm_ops);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "TeamCollection_textSearch_idx" ON "TeamCollection" USING GIN (titleSearch);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "TeamRequest_textSearch_idx" ON "TeamRequest" USING GIN (titleSearch);
|
||||
|
||||
Reference in New Issue
Block a user