I have a table that stores a conversation between two people.

The data will look something like this:

CREATE TABLE foo AS SELECT $$[ { "user": 1, "timestamp": 1, "message": "First message" }, { "user": 2, "timestamp": 2, "message": "Second message" }, { "user": 2, "timestamp": 3, "message": "Debounced message from same user" }, { "user": 1, "timestamp": 4, "message": "Last message" } ]$$::jsonb AS jsondata;

I never need to look up each message individually, so I just want to store the whole conversation in a single jsonb field. I need to perform a full-text search across all of the messages.

My first thought was to create a new text column, concat all of the messages into one long string, and create a trigram GIN index on that column.