My table has the following columns:
- content_vector tsvector
- lang VARCHAR(50)
I'm struggling with creating a GIN index.
Approach one: Explicit type casting
CREATE INDEX pages_vector_ix ON pages USING GIN (to_tsvector(lang::regconfig, content_vector));
This creates the following error despite using an explicit type cast as described in this post:
function to_tsvector(regconfig, tsvector) does not exist
Approach two: Altering column's type
It should also be possible to change the column type to reconfig according to this post:
ALTER TABLE pages ALTER COLUMN lang TYPE reconfig USING lang::reconfig;
Now I'm getting an error because apparently I've stored languages in the database that can't be used as a text search configuration, for example:
text search configuration "afrikaans" does not exist
This error makes me question if it's possible to set a GIN index at all if there are potentially languages stored in the database that are not supported by Postgres.
Additional information
select * from pg_catalog.pg_ts_config;
results in
cfgname | cfgnamespace | cfgowner | cfgparser
------------ -------------- ---------- -----------
simple | 11 | 10 | 3722
danish | 11 | 10 | 3722
dutch | 11 | 10 | 3722
english | 11 | 10 | 3722
finnish | 11 | 10 | 3722
french | 11 | 10 | 3722
german | 11 | 10 | 3722
hungarian | 11 | 10 | 3722
italian | 11 | 10 | 3722
norwegian | 11 | 10 | 3722
portuguese | 11 | 10 | 3722
romanian | 11 | 10 | 3722
russian | 11 | 10 | 3722
spanish | 11 | 10 | 3722
swedish | 11 | 10 | 3722
turkish | 11 | 10 | 3722
CodePudding user response:
As content_vector is already a tsvector, just build the index on it. to_tsvector doesnt take a tsvector as it's second argument, not would it make sense to.