How to create index on JSON field in Postgres?
Found:
CREATE TABLE publishers(id INT, info JSON); CREATE INDEX ON publishers((info->>'name'));
As stated in the comments, the subtle difference here is ->>
instead of ->
. The former one returns the value as text, the latter as a JSON object.