Say I have a table with a jsonb column that contains data structured like this:
{
"records": [
{
"id": 1,
"tag": "address"
},{
"id": 1,
"tag": "receipt"
}
]
}
I'd like to be able to index this column such that I can request "give me all rows where there is a record of type 'receipt'".
I'm trying to find an expression that would output a jsonb array that looks like
["address","receipt"]
so then I can plug that expression into
CREATE INDEX ON t1 USING GIN (expr)
I've been playing around with all different combinations of the JSONB functions, but I think I'm in over my head.