0

I've found a strange example where a generated column doesn't seem to update when I would expect it to.

create table example (
  "id" bigserial primary key,
  "value" text
);
insert into example ("value") values
  ('A'),
  ('B'),
  ('C');
alter table example add column "vector" tsvector generated always as (to_tsvector('english', coalesce("value", ''))) stored;
insert into example ("value") values 
  ('some'),
  ('thing');

I would expect all the vector columns to be updated and contain a vector of the contents of the value column, but some are and some aren't. Even running an update doesn't fill the column. It basically looks like:

id value vector
1 A
2 B 'b':1
3 C 'c':1
4 some
5 thing 'thing':1

The strangest thing is I have tried dropping the column, then re-adding it and I get the exact same results. I've also had times where updating the value column generates the vector, but when I set the value column back to the previous value the vector is blank again.

What am I missing here?

user2659205
  • 157
  • 1
  • 1
  • 7
  • 1
    What specifically is the problem? Are you talking about 'a' and 'some' being stop words? – jjanes Aug 25 '23 at 09:55
  • Yeah, the vector column should have been updated with a tsvector containing the contents of the value column like rows 2,3, and 5. – user2659205 Aug 25 '23 at 14:55

1 Answers1

0

I found the issue. When using the 'english' config for to_tsvector it is excluding some words from the vector. By changing the config to 'simple' my issue was fixed.

user2659205
  • 157
  • 1
  • 1
  • 7