maxmello
06/22/2021, 3:52 PMindexType
to Table.index
such that it uses the USING GIN (...);
syntax, but the class Index
only allows indices on `Column`s, not on something like ExpressionWithColumnType
, so something like this seems impossible:
CREATE INDEX idx_fts_post ON post USING gin((setweight(to_tsvector(title),'A') || setweight(to_tsvector(content), 'B')));
Is there a workaround for that? Sadly the Index
class is not open, and therefore I cannot create a subclass with modified behavior. Can one create something like a fake column and get away with it? (Note: I already created custom Exposed functions to use the postgres-specific functions like to_tsvector
)
Maybe it would also be possible to modify the Exposed code to allow something like this in the future? When I see the usage of columns
in Index
, it really seems that if one would provide a custom name for the index and add some if(columnLike is Column<*>)
to the parts where behavior is dependent on the it actually being a column of the table, this would not be a breaking change to make.