I am using GIN indexes with the pg_trgm
module for indexing varchar
fields. So, to define an index I have to write something like this:
CREATE INDEX gin_field_idx ON table_name USING gin (field gin_trgm_ops);
If I exclude the operator class (git_trgm_ops
) and write:
CREATE INDEX gin_field_idx ON table_name USING gin (field);
PostgreSQL will raise an error:
ERROR: data type character varying has no default operator class for access method "gin"
HINT: You must specify an operator class for the index or define a default operator class for the data type.
How do I define a default operator method from the module?
This does not help. It describes how to define a new operator class from extension operators and functions. But I have to define the default operator class from a module.
Any help will be appreciated :-).
pg_trgm
in order to save a few characters when creating indexes?pg_trgm
to database of large Ruby on Rails(RoR) project. RoR have two ways of migrating database: 1 - byrake db:migrate
or 2 - by loadingschema.rb
. In both cases it breaks older migrations indexes, those already has GIN index type, because they do not have described class. So i want to add default class for not to break older migrations.gin("somecol", gin_trgm_ops)
. And I have the extension created too.