I'm working in Postgres 9.6.5. I have the following table:
id | integer
data | jsonb
The data in the data
column is nested, in the form:
{ 'identification': { 'registration_number': 'foo' }}
I'd like to index registration_number
, so I can query on it. I've tried this (based on this answer):
CREATE INDEX ON mytable((data->>'identification'->>'registration_number'));
But got this:
ERROR: operator does not exist: text ->> unknown
LINE 1: CREATE INDEX ON psc((data->>'identification'->>'registration... ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
What am I doing wrong?