Question is regarding partial GIN indexes construction.
I have a following table.
-- auto-generated definition
create table archives_subtitles
(
id serial not null
constraint archives_subtitles_pkey
primary key,
episode_number smallint not null
constraint archives_subtitles_episode_number_check
check (episode_number >= 0),
text text not null,
language varchar(2) not null
season_id integer not null
constraint archives_subtitles_season_id_e3690b93_fk_archives_
references archives_seasonmodel
deferrable initially deferred,
constraint archives_subtitles_season_id_episode_number_fec69da8_uniq
unique (season_id, episode_number, language)
);
I want to create partial GIN index for FTS like this one:
CREATE INDEX CONCURRENTLY IF NOT EXISTS test ON archives_subtitles
USING GIN
(to_tsvector('english', text))
WITH (fastupdate = off)
WHERE language = 'en'
;
Problem is that I need to specify few dozens languages in to_tsvector and in WHERE language = 'language_code'
Is it possible to somehow include few options with a few different (to_tsvector('language_name', text)) / WHERE language = 'language_code' pairs inside the index definition instead of manually repeating yourself like this:
CREATE INDEX CONCURRENTLY IF NOT EXISTS test1 ON archives_subtitles
USING GIN
(to_tsvector('english', text))
WITH (fastupdate = off)
WHERE language = 'en'
;
CREATE INDEX CONCURRENTLY IF NOT EXISTS test2 ON archives_subtitles
USING GIN
(to_tsvector('french', text))
WITH (fastupdate = off)
WHERE language = 'fr'
;
CREATE INDEX CONCURRENTLY IF NOT EXISTS test3 ON archives_subtitles
USING GIN
(to_tsvector('russian', text))
WITH (fastupdate = off)
WHERE language = 'ru'
;
etc
etc
etc
…
Thank you.