I'm using the pg_search gem to add full text search to a table in my app.
My problem is when trying to create a trigger to keep the tsv column up to date after any change, this is my migration:
class AddStoreItemsIndex < ActiveRecord::Migration[5.0]
def up
add_column :store_items, :tsv, :tsvector
add_index :store_items, :tsv, using: "gin"
execute <<-SQL
CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE
ON store_items FOR EACH ROW EXECUTE PROCEDURE
tsvector_update_trigger(
tsv, 'pg_catalog.english', title, full_description, recommended_age, related_intelligences
);
SQL
end
...
end
In this case, the related_intelligences column is an Array, so when trying to query this I get the following error:
ActiveRecord::StatementInvalid:
PG::DatatypeMismatch: ERROR: column "related_intelligences" is not of a character type
How can I include arrays within this tsv vector column?