How to create index in json field in Postgres 9.3

In PostgreSQL 9.3 Beta 2 (?), How do I create an index in a JSON field? I tried it with the -> operator used for hstore , but got the following error:

  CREATE TABLE publishers(id INT, info JSON); CREATE INDEX ON publishers((info->'name')); 

ERROR: json data type does not have a default operator class for the btree access method TIP. You must specify an operator class for the index or define a default operator class for the data type.

+64
postgresql
Jul 23 '13 at 10:00
source share
1 answer

Found:

 CREATE TABLE publishers(id INT, info JSON); CREATE INDEX ON publishers((info->>'name')); 
+109
Jul 23 '13 at 11:25
source share



All Articles